Console.WriteLine("请输入球员的人数:"); int a = Convert.ToInt32(Console.ReadLine()); int[] cj = new int[a]; for (int i = 0; i < a; i++) { Console.WriteLine("请输入第{0}个球员的成绩:", i + 1); cj[i] = Convert.ToInt32(Console.ReadLine()); } for (int j = 0; j < a - 1; j++) //冒泡排序 { for (int k = 0; k < a - 1; k++) { if (cj[k] <= cj[k + 1]) { int zj = cj[k]; cj[k] = cj[k + 1]; cj[k + 1] = zj; } } } Console.WriteLine("*************************"); Console.WriteLine("成绩从大到小为"); for (int z = 0; z < a; z++) { Console.WriteLine(cj[z]); }
时间: 2024-10-24 07:26:10