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();
  • 相关阅读:
    BM求递推式模板
    主席树浅谈
    DSU on Tree浅谈
    树链剖分浅谈
    省选模拟八 题解
    提答题 总结
    交互题 总结
    省选模拟七 题解
    省选模拟六 题解
    省选模拟五 题解
  • 原文地址:https://www.cnblogs.com/qixinjian/p/4587803.html
Copyright © 2011-2022 走看看