using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 结构体 { class Program { struct tongji { public string xm; public string sex; public int old; public double h; public double tz; } static void Main(string[] args) { Console.Write("请输入人数:"); int a=int.Parse(Console.ReadLine()); ArrayList arr=new ArrayList(); for (int i = 0; i < a; i++) { tongji s = new tongji(); Console.WriteLine("正在输入第" + (i + 1) + "个人员信息"); Console.Write("请输入姓名:"); s.xm = Console.ReadLine(); Console.Write("请输入性别:"); s.sex = Console.ReadLine(); Console.Write("请输入年龄:"); s.old = int.Parse(Console.ReadLine()); Console.Write("请输入身高:"); s.h = double.Parse(Console.ReadLine()); Console.Write("请输入体重:"); s.tz = double.Parse(Console.ReadLine()); arr.Add(s); } for (int j = 0; j < a - 1; j++) { for (int k = j+1; k <a; k++) { if (((tongji)arr[j]).old > ((tongji)arr[k]).old) { tongji zhong = (tongji)arr[j]; arr[j] = arr[k]; arr[k] = zhong; } } } Console.Write("姓名 性别 年龄 身高 体重 "); for (int p = 0; p < a; p++) { Console.Write(((tongji)arr[p]).xm + " " + ((tongji)arr[p]).sex + " " + ((tongji)arr[p]).old + " " + ((tongji)arr[p]).h + " " + ((tongji)arr[p]).tz + " "); } Console.ReadLine();