presentation error
在一个论坛上做题,改了半天老是presentation error,望高手指正刚刚忘了贴网址……http://
程序代码:
import java.util.*; public class Main { public static void main(String[] args) { int n,k; Scanner scan = new Scanner(System.in); while(scan.hasNext()){ n = scan.nextInt(); k = scan.nextInt(); int[][] temp = new int[n][k]; int[] sum = new int[n]; for(int i = 0; i < temp.length; i++){ for (int j = 0; j < temp[0].length; j++){ temp[i][j] = scan.nextInt(); sum[i] += temp[i][j]; } } int [] average = new int[k]; for (int i = 0; i < temp[0].length; i++){ for (int j = 0; j < temp.length; j++ ) average[i] += temp[j][i]; } for (int i = 0; i < sum.length; i++) System.out.print(sum[i] + " "); System.out.println(); double a; for (int i = 0; i < average.length; i++){ a = average[i]/(double)n; if(a * 10 % 10 < 5) System.out.print((int)a + " "); else System.out.print((int)(a +1) + " "); } System.out.println(); System.out.println(); } } }
[ 本帖最后由 heartnheart 于 2010-2-21 22:22 编辑 ]