Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //input arrays with ";" between them
- String[] temp = scanner.nextLine().split(";");
- //input integers with white space between them
- int[][] arr = new int[4][4];
- for(int i = 0; i < 4; i++){
- String[] tempA = temp[i].split("\s");
- for(int j = 0; j < 4; j++){
- arr[i][j] = Integer.parseInt(tempA[j]);
- }
- }
- //input integers with white space between them
- ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
- for(int i = 0; i < 4; i++){
- String[] tempA = temp[i].split("\s");
- list.add(i, new ArrayList<Integer>());
- for(int j = 0; j < 4; j++){
- list.get(i).add(j, Integer.parseInt(tempA[j]));
- }
- }
- runningSum2DArray(arr, 1);
- runningSum2DArray(arr, 2);
- runningSum2DArrayList(list, 3);
- runningSum2DArrayList(list, 4);
- scanner.close();
- }
Add Comment
Please, Sign In to add comment