分别使用while do-while for 三种语句编程求1-100的累加和.

问题描述:

分别使用while do-while for 三种语句编程求1-100的累加和.

Console.WriteLine("请输入起点整数");
int numberOne = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入终点整数");
int numberTwo = Convert.ToInt32(Console.ReadLine());
int i = numberOne;
int sum = 1;
while (numberOne {
sum = sum + numberOne;
numberOne++;
}
Console.WriteLine("从{0}到{1}之和为{2}", i, numberTwo, sum);
int i=1;
int sum = 0;
do
{
sum = sum + i;
i++;
}while(i