#代码string strNumber = ""; int max = 0;while (strNumber != "fuck") { Console.WriteLine("请输入一个数字,输入fuck,我们将显示你输入的数字中的最大值"); strNumber = Console.ReadLine(); if (strNumber != "fuck") { try { int number = Convert.ToInt32(strNumber); if (number > max) { max = number; } } catch { Console.WriteLine("输入有误,请重新输入"); } } else{ Console.WriteLine("您刚才输入的数字中最大值是{0}", max); } } Console.ReadKey();#效果 图片发自简书App