zoukankan      html  css  js  c++  java
  • 输入个人信息按年龄大小排列

    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();
  • 相关阅读:
    Linux查看系统资源占用
    覆盖索引有何用?
    Java8新特性
    架构的力量!!2016解密互联网公司架构技术
    作为程序员,如何防辐射?
    Mysql查询正在运行的事务以及杀掉它
    Hbase设计实战
    不可不知的网络知识与工具
    MySQL数据库事务剖析
    dos插入mysql乱码
  • 原文地址:https://www.cnblogs.com/qixinjian/p/4587803.html
Copyright © 2011-2022 走看看