> 其他 >
用C#设计一个控制台应用程序项目,输入正整数n,计算s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n)
用C#做,谢谢
人气:361 ℃ 时间:2020-03-21 19:53:55
解答
static void Main(string[] args)
{
int intInput = 0;
while (true)
{
Console.Write("请输入一个大于0的正整数:");
string strInput = Console.ReadLine();
if (int.TryParse(strInput,out intInput) && intInput > 0)
break;
}
int result = 0;
for (int i = 1; i
推荐
猜你喜欢
© 2026 79432.Com All Rights Reserved.
电脑版|手机版