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();
  • 相关阅读:
    自定义 ListView
    linux IO重定向
    Facebook开源C++组件库Folly
    在vi按了ctrl+s后
    让Erlang服务器后台运行
    mysql innodb 性能相关参数
    linux 网卡驱动升级
    kernel panic
    32位Linux下使用2G以上大文件的几个相关宏的关系
    CentOS安装erlang
  • 原文地址:https://www.cnblogs.com/qixinjian/p/4587803.html
Copyright © 2011-2022 走看看