C#编写1加到100的代码

循环函数
2024-12-04 09:02:38
推荐回答(5个)
回答1:

int count = 0;
for(int i=1;i<=100;i++)
{
count = count + i;
}

上面写的明白了把!

回答2:

using System;

namespace ConsoleApplication3
{
class Program
{
static void Main()
{
int num = 0;
for (int i = 1; i <= 100; i++)
{
num += i;
}
Console.WriteLine(num);
}
}
}

回答3:

int count = 0;
for(int i=1;i<=100;i++)
{
count = count + i;
}
Response.Write(count.ToString());

回答4:

using System;
class lyf;
{
int i,sum=0;
for(i=1;i<100;i++)
{
sum+=i;
}
Console.WriteLine("1到一百的和是{0}",sum);
}

回答5:

太菜了吧
int count = 0;
for(int i=1;i<=100;i++)
{
count = count + i;
}
Response.Write(count.ToString());