本文介绍了打印学生分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            Student std = new Student();
            std.ID = i;
            std.Name = "Name" + i;

            std.Class = classes[cls.Next(0, 3)];
            std.Branch = Branches[brnc.Next(0, 3)];
            std.Age = ag.Next(17,22);
            std.SocialMarks = marks1.Next(50, 100);
            std.MathsMarks = marks2.Next(50, 100);
            std.ScienceMarks = marks3.Next(50, 100);
            std.TotalMarks = std.MathsMarks + std.SocialMarks + std.ScienceMarks;
            std.AverageMarks = std.TotalMarks / 3.0;
            students.Add(std);
        }

        Console.WriteLine("ID | Name | Age | Class | Branch | Total Marks");
        foreach (Student std in students)
        {
            Console.WriteLine(std.ID + " | " + std.Name + " | " + std.Age + " | " + std.Class + " | " + std.Branch + " | " + std.TotalMarks);
        }
        Console.ReadLine();
    }
}

推荐答案


这篇关于打印学生分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 11:05