日期:2014-05-20 浏览次数:20771 次
public class Test { public static void main(String args[]) { Scanner input = new Scanner(System.in); int[][] ops = null; boolean flag = true; int countTest = 0; while (flag) { System.out.print("多少组测试数据:\n"); try { countTest = input.nextInt(); ops = new int[countTest][3]; } catch (Exception e) { // e.printStackTrace(); continue; } flag = false; } System.out.print("请输入数据:\n"); for(int index = 0;index<countTest*2; index++ ){ ops[index/2][index%2] = input.nextInt(); if((index+1)%2 == 0){ ops[(index-1)/2][2] = ops[(index-1)/2][0]+ops[(index-1)/2][1]; } } for(int index = 0;index<countTest;index++){ System.out.println(ops[index][2]); } } }