Guest User

Untitled

a guest
Feb 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. public static void main(String[] args) {
  2. Scanner scanner = new Scanner(System.in);
  3.  
  4. //input arrays with ";" between them
  5. String[] temp = scanner.nextLine().split(";");
  6.  
  7. //input integers with white space between them
  8. int[][] arr = new int[4][4];
  9. for(int i = 0; i < 4; i++){
  10. String[] tempA = temp[i].split("\s");
  11. for(int j = 0; j < 4; j++){
  12. arr[i][j] = Integer.parseInt(tempA[j]);
  13. }
  14. }
  15.  
  16. //input integers with white space between them
  17. ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
  18. for(int i = 0; i < 4; i++){
  19. String[] tempA = temp[i].split("\s");
  20. list.add(i, new ArrayList<Integer>());
  21. for(int j = 0; j < 4; j++){
  22. list.get(i).add(j, Integer.parseInt(tempA[j]));
  23. }
  24. }
  25.  
  26. runningSum2DArray(arr, 1);
  27. runningSum2DArray(arr, 2);
  28. runningSum2DArrayList(list, 3);
  29. runningSum2DArrayList(list, 4);
  30.  
  31. scanner.close();
  32.  
  33. }
Add Comment
Please, Sign In to add comment