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();
        }
    }
}
二百个不间断的重复,只是让我看到了人的命运无法改变这一事实而已。
原文地址:https://www.cnblogs.com/dlexia/p/4439395.html