Console.WriteLine ("请输入你希望排序_____个年龄(整数类型):");
int sum = int.Parse (Console.ReadLine ());
Console.WriteLine ("请输入{0}个年龄(整数类型):", sum);
//初始化数组,给每一个输入数据存入当前创建的数组
int[] arr = new int[sum];
for (int i = 0; i < sum; i++) {
arr [i] = int.Parse (Console.ReadLine ());
}
for (int i = 0; i < arr.Length - 1; i++) {
for (int j = i + 1; j < arr.Length; j++) {
if (arr [i] > arr [j]) {
int temp;
temp = arr [i];
arr [i] = arr [j];
arr [j] = temp;
}
}
}
//反向遍历
Array.Reverse (arr);
foreach (int t in arr) {
Console.WriteLine (t);
}