int sum = 0;
Console.Write("请输入数字:");
int shu = int.Parse(Console.ReadLine());
for (int i = 1; i <= shu; i++)
{
sum = sum + i;
}
Console.WriteLine("结果为:"+sum);
时间: 2024-11-07 03:27:40