fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. class student
  5. {
  6. public string 学号 { get; set; }
  7. public string 姓名 { get; set; }
  8. public bool 性别 { get; set; }
  9. public int 年龄 { get; set; }
  10. public student(string 学号, string 姓名, bool 性别, int 年龄)
  11. {
  12. this.学号 = 学号;
  13. this.姓名 = 姓名;
  14. this.性别 = 性别;
  15. this.年龄 = 年龄;
  16. }
  17. }
  18.  
  19. public class Test
  20. {
  21. public static void Main()
  22. {
  23. student[] arr = new student[10];
  24. for (int i = 0; i < 10; i++)
  25. {
  26. string 学号 = Console.ReadLine();
  27. string 姓名 = Console.ReadLine();
  28. bool 性别 = Console.ReadLine() == "男";
  29. int 年龄 = int.Parse(Console.ReadLine());
  30. arr[i] = new student(学号, 姓名, 性别, 年龄);
  31. }
  32. foreach (student s in arr.OrderBy(x => x.年龄))
  33. {
  34. Console.WriteLine("{0} {1} {2} {3}", s.学号, s.姓名, s.性别, s.年龄);
  35. }
  36. }
  37. }
Success #stdin #stdout 0.01s 29808KB
stdin
1
a1
男
20
2
a2
男
22
3
a3
女
24
4
a4
男
19
5
a5
女
22
6
a6
男
26
7
a7
男
25
8
a8
女
30
9
a9
男
24
10
a10
男
20
stdout
4 a4 True 19
1 a1 True 20
10 a10 True 20
2 a2 True 22
5 a5 False 22
3 a3 False 24
9 a9 True 24
7 a7 True 25
6 a6 True 26
8 a8 False 30