效果

图片发自简书App
代码
Console.WriteLine("请输入6个数字");
int[] a = new int[6];
try
{
for (int i = 0; i < a.Length; i++)
{
Console.Write("请输入{0}个数字:", i + 1);
a[i] = Convert.ToInt32(Console.ReadLine());
}
for (int i = 0; i < a.Length - 1; i++) //比较的次数
{
for (int j = 0; j < a.Length - 1 - i; j++) //交换的次数
{
if (a[j]<a[j+1])
{
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
Console.WriteLine("排序后的成绩为:");
for (int i = 0; i < a.Length; i++)
{
Console.Write("{0}\t",a[i]);
}
}
catch
{
Console.WriteLine("输入格式错误");
}
Console.ReadKey();