fork download
  1. class Main{
  2. public static void main (String[] args) throws java.lang.Exception {
  3. java.util.Scanner i = new java.util.Scanner(System.in);
  4. int n = i.nextInt();
  5. int m = i.nextInt();
  6. int array1[][] = new int[n][m];
  7. int array2[][] = new int[n][m];
  8. int array_sum[][] = new int[n][m];
  9. for(int k = 0; k < n; k++){
  10. for(int j = 0; j < m; j++){
  11. array1[k][j] = i.nextInt();
  12. }
  13. }
  14. for(int k = 0; k < n; k++){
  15. for(int j = 0; j < m; j++){
  16. array2[k][j] = i.nextInt();
  17. }
  18. }
  19. for(int k = 0; k < n; k++){
  20. for(int j = 0; j < m; j++){
  21. array_sum[k][j] = array1[k][j] + array2[k][j];
  22. System.out.print (array_sum[k][j] + " ");
  23. }
  24. System.out.println();
  25. }
  26. }
  27. }
Success #stdin #stdout 0.12s 35816KB
stdin
3 4
3 4 5 6
1 2 3 4
7 6 5 4

0 0 -3 -2
-1 3 4 5
5 6 1 2
stdout
3 4 2 4 
0 5 7 9 
12 12 6 6