#代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
string strNumber = "";
int max = 0;
while (strNumber != "end")
{
Console.WriteLine("请输入一个数字,输入end,我们将显示你输入的数字中的最大值");
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);
}
}
Console.ReadKey();
}
}
}
#效果
![](https://img.haomeiwen.com/i14494316/91e48b0f8b0df9c5.png)
网友评论