美文网首页
2018-11-14(2)

2018-11-14(2)

作者: 一只皮皮橙 | 来源:发表于2018-11-17 13:12 被阅读0次

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

//不断要求用户输入一个数字(假定用户输入的都是正整数),当用户输入end的时候显示刚才输入的数字中的最大值

string strnumber = "";

int max = 0;

do

{

Console.WriteLine("请用户输入一个正整数");

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

}

} while (strnumber != "end");

Console.ReadKey();

}

}

}

相关文章

网友评论

      本文标题:2018-11-14(2)

      本文链接:https://www.haomeiwen.com/subject/wlwbfqtx.html