分别使用while do-while for 三种语句编程求1-100的累加和.
人气:326 ℃ 时间:2020-02-20 15:03:05
解答
Console.WriteLine("请输入起点整数");
int numberOne = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入终点整数");
int numberTwo = Convert.ToInt32(Console.ReadLine());
int i = numberOne;
int sum = 1;
while (numberOne < numberTwo)
{
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
推荐
- 分别用 while,do while 和for 循环计算1+2+……+100的和,C语言编程
- 2、分别用三种循环语句(while语句、do-while语句、for语句),实现求1~100的累加和
- 用JAVA语言编程 求1!+2!+3!+4!+5!+6!+7!+8!+9!+10!.(要求:使用while、do-while、for三种语句
- 求1-100的累加和分别用while,do...while和for这两种循环语句实现
- 分别用for ,while ,do while 语句编程计算1-100之间奇数和
- WE COULDN'T CHOOSE WHERE WE WILL BE BORN.这句话对吗?
- 集合A.B定义A-B={x|x∈A,且x¢B},A*B=(A-B)∪(B-A)若A={1,3,5}B={3,5,7,9}则A*B=
- 数学中心对称图形定理
猜你喜欢