c#编写程序,使用do-while循环语句,从键盘上输入10个数,求出它们的和

如题所述

第1个回答  2018-12-24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace do_while
{
class Program
{
static void Main(string[] args)
{
int sum = 0;
int i = 0;
do
{
Console.WriteLine("输入第" + (i + 1) + "个数");
int s = int.Parse(Console.ReadLine());
sum = s + sum;
i++;
}
while (i < 10);
Console.WriteLine("十个数相加为: " + sum);
Console.ReadLine();
}
}
}

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网