关于java二维数组的题,请高手讲解一下。
定义一个20*5的二维数组,用来存储某班级20位学员的5门课的成绩,这5门课按存储顺序依次为:coreC++,coreJava,Servlet,JSP和EJB(1)给二维...
定义一个20*5的二维数组,用来存储某班级20位学员的5门课的成绩,这5门课按存储顺序依次为:core C++ , coreJava , Servlet ,JSP和EJB
(1)给二维数组的每个元素赋值0~100;
(2)按照列表的方式输出这些学员的每门课程的成绩
(3)要求编写程序求每个学员的总分,将其保留在另外一个一维数组
(4)要求编写程序求所有学员的某门课程的平均分 展开
(1)给二维数组的每个元素赋值0~100;
(2)按照列表的方式输出这些学员的每门课程的成绩
(3)要求编写程序求每个学员的总分,将其保留在另外一个一维数组
(4)要求编写程序求所有学员的某门课程的平均分 展开
2个回答
2011-10-13
展开全部
那个平均分不写了.
package tomcat;
public class Nume {
public static void main(String [] args){
int sum=0;
int all[]=new int[20];
int ping[]=new int[20];
int score[][]={{1,80,61,87,45,78},{2,87,60,89,45,78},{3,87,69,80,45,78},
{4,87,69,89,40,77},{5,87,69,89,45,75},{6,80,69,79,45,76},
{7,81,60,79,45,78},{8,87,69,80,45,78},{9,87,61,89,40,78},
{10,87,65,89,45,70},{11,87,69,89,40,78},{12,83,69,69,45,78},
{13,81,60,69,45,78},{14,80,69,89,45,78},{15,84,69,89,40,78},
{16,80,69,79,45,78},{17,84,69,89,45,78},{18,85,69,89,45,70},
{19,87,69,59,40,78},{20,85,69,80,45,78}};
String name[]={"C++","Java","Servlet","JSP","EJB"};
System.out.print("学号\t");
for(int i=0;i<5;i++)
{
System.out.print(name[i]+"\t");
}
System.out.println();
for(int i=0;i<20;i++)
{
for(int j=0;j<6;j++)
{
System.out.print(score[i][j]+"\t");
all[i]+=score[i][j]-i;//求每个人的总分,包括学号
}
System.out.println();
}
//从all[0]到all[19]就是每个人的总分了,我写成下面这样了
for(int i=1;i<all.length+1;i++)
{
all[i-1]-=i;//因为学号也在里面,减掉了学号
System.out.println("第"+i+"个人总分"+all[i-1]);
}
}
}
package tomcat;
public class Nume {
public static void main(String [] args){
int sum=0;
int all[]=new int[20];
int ping[]=new int[20];
int score[][]={{1,80,61,87,45,78},{2,87,60,89,45,78},{3,87,69,80,45,78},
{4,87,69,89,40,77},{5,87,69,89,45,75},{6,80,69,79,45,76},
{7,81,60,79,45,78},{8,87,69,80,45,78},{9,87,61,89,40,78},
{10,87,65,89,45,70},{11,87,69,89,40,78},{12,83,69,69,45,78},
{13,81,60,69,45,78},{14,80,69,89,45,78},{15,84,69,89,40,78},
{16,80,69,79,45,78},{17,84,69,89,45,78},{18,85,69,89,45,70},
{19,87,69,59,40,78},{20,85,69,80,45,78}};
String name[]={"C++","Java","Servlet","JSP","EJB"};
System.out.print("学号\t");
for(int i=0;i<5;i++)
{
System.out.print(name[i]+"\t");
}
System.out.println();
for(int i=0;i<20;i++)
{
for(int j=0;j<6;j++)
{
System.out.print(score[i][j]+"\t");
all[i]+=score[i][j]-i;//求每个人的总分,包括学号
}
System.out.println();
}
//从all[0]到all[19]就是每个人的总分了,我写成下面这样了
for(int i=1;i<all.length+1;i++)
{
all[i-1]-=i;//因为学号也在里面,减掉了学号
System.out.println("第"+i+"个人总分"+all[i-1]);
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询