代码图

效果图

代码
int max = 0;
int a = 0;
string b = "";
do
{
try
{
Console.WriteLine("请输入一个数字");
b = Console.ReadLine();
if (b != "end")
{
a = Convert.ToInt32(b);
if (a > max)
{
max = a;
}
}
}
catch
{
Console.WriteLine("输入的不是整数请重试");
}
} while (b !="end");
Console.WriteLine("最大的数字为{0}",max);
Console.ReadKey();
}
网友评论