zoukankan      html  css  js  c++  java
  • stuct+ArrayList的for用法

    namespace ConsoleApplication1
    {
        class Program
        {
            struct xs
            {
               public string name;
                public double shuxue;
                public double yuwen;
                public double waiyu;
                public double zongfen;
            }
            static void Main(string[] args)
            {
                ArrayList al = new ArrayList();
                Console.Write("请输入学生的个数:");
                int n = Convert.ToInt32(Console .ReadLine ());
                    for (int i = 1; i <= n; i++)
                {
                    xs t = new xs();
                    Console.Write("输入第"+i+"个同学的姓名:");
                    t.name = Console.ReadLine();
                    Console.Write("请输入数学分数:");
                    t.shuxue = Convert.ToInt32(Console.ReadLine());
                    Console.Write("请输入语文分数:");
                    t.yuwen = Convert.ToInt32(Console.ReadLine());
                    Console.Write("请输入外语分数:");
                    t.waiyu= Convert.ToInt32(Console.ReadLine());
                    t.zongfen = t.shuxue + t.yuwen + t.waiyu;
                    al.Add(t);
                }
                for (int i = 1; i <= al.Count-1; i++)
                {
                    for (int j = 1 ; j <= al.Count-i; j++)
                    {
                       
                        if (((xs)al[j]).zongfen >((xs)al[j-1]).zongfen )
                        {
                            xs tepm = (xs)al[j];
                            al[j] = al[j - 1];
                            al[j - 1] = tepm;
                        }
                    }
                }
                for (int i = 0; i <al.Count ; i++)
                {
                    Console.WriteLine("姓名" + ((xs)al[i]).name + "	数学" + ((xs)al[i]).shuxue + "	语文" + ((xs)al[i]).yuwen + "	外语" + ((xs)al[i]).waiyu + "	总分" + ((xs)al[i]).zongfen + "	名次" + (i+1));
                }
                Console.ReadLine();
            }
        }
    }
    二百个不间断的重复,只是让我看到了人的命运无法改变这一事实而已。
  • 相关阅读:
    使用RAID与LVM磁盘阵列技术
    挂载硬件设备和磁盘容量配额
    文件存储结构(FHS标准)物理设备命名规则(udev)和文件系统
    文件访问控制列表
    逻辑漏洞
    web渗透思维导图
    常见漏洞简单测试整理
    Python知识点图片
    python控制流
    Python小知识点+保留字
  • 原文地址:https://www.cnblogs.com/dlexia/p/4439395.html
Copyright © 2011-2022 走看看