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 <= intInput; i++)
{
for (int j = 1; j <= i; j++)
{
result += j;
}
}
Console.Write(result.ToString());
Console.Read();
}
本回答被提问者和网友采纳