2018-11-14(2)

2018-11-17  本文已影响0人  一只皮皮橙

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

//不断要求用户输入一个数字(假定用户输入的都是正整数),当用户输入end的时候显示刚才输入的数字中的最大值

string strnumber = "";

int max = 0;

do

{

Console.WriteLine("请用户输入一个正整数");

strnumber = Console.ReadLine();

if (strnumber != "end")

{

try

{

int number = Convert.ToInt32(strnumber);

if (number > max)

{

max = number;

}

}

catch

{

Console.WriteLine("这个程序错误");

}

}

else

{

Console.WriteLine("刚才输入数字的最大值{0}",max);

}

} while (strnumber != "end");

Console.ReadKey();

}

}

}

上一篇 下一篇

猜你喜欢

热点阅读