当前位置:编程学习 > C/C++ >>

c语言二维表设计

设计一个成绩管理的二维表,输入学生名,结果输出学生所在班级及数学语文的成绩,能吗?我一点也不懂,请帮帮忙吧
答案:
class GradeStudents {

public static void main(String arguments[]) {

int[][] student = new int[6][6];

int[] janice = { 90,85,85,75,70,95 };

int[] mikey = { 95,85,85,70,75,90 };

int[] nicki = { 85,80,85,95,100,100 };

int[] bernice = { 80,90,90,80,85,95 };

int[] ernest = { 75,45,80,95,90,90 };

int[] bigMike = { 90,90,90,95,70,65 };

student[0] = janice;

student[1] = mikey;

student[2] = nicki;

student[3] = bernice;

student[4] = ernest;

student[5] = bigMike;

int gradeSum = 0;

int[] studentSum = new int[6];

// Loop through the students

for (int i = 0; i < 6; i++) {

System.out.println("Student #" + i);

studentSum = 0;

// Loop through each student's grades

for (int j = 0; j < 6; j++) {

gradeSum = gradeSum + student[j];

studentSum = studentSum + student[j];

}

System.out.println(" Average grade: "

+ studentSum / 6);

}

System.out.println("\nAverage grade of all students: " +

gradeSum / 36);

}

}

上一个:c语言程序的含义
下一个:c语言指针的运用

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,