Console.WriteLine ("请输入一个整数:");
int num = int.Parse (Console.ReadLine ());
int[] ageArray = new int[num];
for (int i = 0; i < num; i++) {
Console.WriteLine ("请输入年龄");
ageArray [i] = int.Parse (Console.ReadLine ());
}
for (int i = 0; i < ageArray.Length - 1; i++) {
for (int j = 0; j < ageArray.Length - i - 1; j++) {
if (ageArray [j] > ageArray [j + 1]) {
int temp = ageArray [j];
ageArray [j] = ageArray [j + 1];
ageArray [j + 1] = temp;
}
}
}
foreach (int t in ageArray) {
Console.WriteLine (t);
}