2018-11-14

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();

        }

    }

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 循环结构 要么痛苦的坚持游戏结束 可能会升级 要么结束游戏继续的痛苦 可能有遗憾 知识点 (1) . whil...
    拾起_518阅读 2,750评论 0 0
  • #代码 using System; using System.Collections.Generic; using...
    柏建春阅读 1,111评论 0 0
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 7,588评论 0 3
  • /** * 1. 要求用户输入用户名和密码,只要不是admin、888888就一直提示用户名或密码错误,请重新输入...
    晨颜阅读 1,540评论 0 0
  • 无论什么 python web 框架,比如 Django 或者 flask,都需要一个 web 服务器把应用跑起来...
    冬瓜1992阅读 10,909评论 0 2