##
try
{
Console.WriteLine("请随机输入6个数字");
int[] num = new int[6];
for (int i = 0; i < num.Length; i++)
{
Console.WriteLine("请输入第{0}个数字", i + 1);
num[i] = Convert.ToInt32(Console.ReadLine());
}
for (int j = 0; j < num.Length - 1; j++)
{
for (int z = 0; z < num.Length - 1 - j; z++)
{
if (num[z]>num[z+1])
{
int temp = num[z];
num[z] = num[z + 1];
num[z + 1] = temp;
}
}
}
Console.WriteLine("排序后的成绩是");
for (int i = 0; i < num.Length; i++)
{
Console.Write("{0}\t",num[i]);
}
}
catch
{
Console.WriteLine("你输入错误");
}
Console.ReadKey();
网友评论