2018-11-14作业3

 

            string strNumber

= "";

            int max = 0;

            while (strNumber

!= "end")

            {

                Console.WriteLine("请输入一个数字,输入end,我们将显示你输入的数字中的最大值");

                strNumber =Console.ReadLine();

                if (strNumber !="end")

                {

                    try

                    {

                        intnumber = Convert.ToInt32(strNumber);

                        if(number > max)

                        {

                            max = number;

                        }

                    }

                    catch

                    {

                        Console.WriteLine("输入有误,请重新输入");

                    }

                }

                else//输入的是end

                {

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

                }

            }

            Console.ReadKey();

你可能感兴趣的:(2018-11-14作业3)