编写一个程序,冲键盘输入10个数,并对10个数进行排序,输出排序后的结果

如题所述

第1个回答  2015-09-17
static void Main(string[] args)
{
List<int> testMath=new List<int>();

for (int i = 0; i < 10; i++)
{
int t = Convert.ToInt32(Console.ReadLine());

testMath.Add(t);
}
testMath.Sort();
foreach (int i in testMath)
{
Console.WriteLine(i);
}

Console.ReadLine();
}

简单写了一下,未对输入值进行判断,输入非数字会报错,可以自己加下验证本回答被网友采纳