日期:2014-05-20 浏览次数:20669 次
import java.util.*;
public class test {
public static void main(String[] args)
{
Scanner rd = new Scanner(System.in);
int M = rd.nextInt();
int N = rd.nextInt();
int[][] arr = new int[M][N];
int[] score = new int[M];
for(int i=0; i<arr.length; i++)
{
for(int j=0; j<arr[i].length; j++)
{
arr[i][j] = rd.nextInt();
}
}
putScoreFromArray(arr, score);
paint(score);
}
public static void putScoreFromArray(int[][] allStudentScore, int[] score)
{
int sum = 0;
for(int i=0; i<allStudentScore.length; i++)
{
for(int j=0; j<allStudentScore[i].length; j++)
{
sum += allStudentScore[i][j];
}
score[i] = sum / allStudentScore[0].length;
sum = 0;
}
}
public static void paint(int[] score)
{
for(int i=0; i<score.length; i++)
{
System.out.println("The " + (i+1) + " Student Average score is " + score[i]);
}
}
}