我有一个用于获取学生和主题详细信息的锯齿状数组,我使用了 2 个锯齿状数组,一个用于学生详细信息(姓名和 rollno),另一个用于主题详细信息(主题和分数),现在我想总结所有分数特定学生的,谁能告诉我我该怎么做,下面是我的整个代码。
public void GetStudentDetails()
{
Console.WriteLine("Please enter number of Students");
int STUDENTS = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please enter number of Subjects");
int SUBJECTS = Convert.ToInt32(Console.ReadLine()); //0 is reserved for the student name, so the marks starts from the index 1, hence if you set the marks for 3, it will ask for 2 marks
string[][] student_details = new string[STUDENTS][];
string[][] subject_details = new string[SUBJECTS][];
string[][] result_details = new string[STUDENTS][];
StringBuilder stud_sub_info = new StringBuilder();
stud_sub_info.Append("Name\tRoll-No\t");
for (int a = 0; a < STUDENTS; a++)
{
student_details[a] = new string[STUDENTS * 2];
for (int b = 0; b < 2; b++)
{
Console.WriteLine("Enter Student {0} {1}:", a + 1, (b == 0) ? "Name" : "Roll-No");
student_details[a][b] = Console.ReadLine();
}
for (int c = 0; c < SUBJECTS; c++)
{
subject_details[c] = new string[SUBJECTS * 2];
for (int d = 0; d < 2; d++)
{
if (d == 0)
{
Console.WriteLine("Enter Name for Subject {0}", c + 1);
subject_details[c][d] = Console.ReadLine();
stud_sub_info.Append(subject_details[c][d] + "\t");
}
else
{
Console.WriteLine("Enter Marks for {0}", subject_details[c][d - 1]);
subject_details[c][d] = Console.ReadLine();
}
}
}
}
Console.WriteLine(stud_sub_info.ToString());
for (int a = 0; a < STUDENTS; a++)
{
for (int b = 0; b < 2; b++)
{
Console.Write(student_details[a][b] + "\t");
}
for (int c = 0; c < SUBJECTS; c++)
{
for (int d = 0; d < 2; d++)
{
Console.Write(subject_details[c][d] + "\t");
}
}
}
}