class Program
{
static void Main(string[] args)
{
while (true)
{
int a, b; int s = 0;
Console.WriteLine("请输入第一个数:");
a = Convert.ToInt32(Console.ReadLine()); //最简单的循环数,从a到b的和
Console.WriteLine("请输入第二个数:");
b = Convert.ToInt32(Console.ReadLine());
for (int i = a; i <= b; i++) //从a一直加到b
{
s = s + i;
}
Console.WriteLine("那么从"+a+"到"+b+"的和为"+s);
Console.ReadLine();
时间: 2024-10-11 09:25:11