fork download
  1. #include <iostream>
  2. using namespace std;
  3. /*
  4. Declarăm “n” și cele trei matrice.
  5. Citim variabila “n”.
  6. Folosind doua structuri repetitive intercalate citim prima matrice.
  7. Folosind doua structuri repetitive intercalate:
  8. Citim elementul curent.
  9. Facem suma dintre elementul curent situat în prima matrice cu
  10. elementul curent citit și o salvăm în cea de-a treia matrice pe aceeasi pozitie.
  11. Afisam suma calculata.
  12. După închiderea celei de-a doua structuri repetitive, afisam un rand nou.
  13. */
  14.  
  15. const int SIZE = 10;
  16.  
  17. int main() {
  18. int n, one[SIZE + 1][SIZE + 1], two[SIZE + 1][SIZE + 1], three[SIZE +1][SIZE + 1];
  19. cin >> n;
  20. for (int i = 1; i <= n; ++i) {
  21. for (int j = 1; j <= n; ++j) {
  22. cin >> one[i][j];
  23. }
  24. }
  25. for (int i = 1; i <= n; ++i) {
  26. for (int j = 1; j <= n; ++j) {
  27. cin >> two[i][j];
  28. three[i][j] = one[i][j] + two[i][j];
  29. cout << three[i][j] << " ";
  30. }
  31. cout << "\n";
  32. }
  33. return 0;
  34. }//
Success #stdin #stdout 0.01s 5288KB
stdin


10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
->
2 4 6 8 10 12 14 16 18 20
2 4 6 8 10 12 14 16 18 20
2 4 6 8 10 12 14 16 18 20
2 4 6 8 10 12 14 16 18 20
2 4 6 8 10 12 14 16 18 20
2 4 6 8 10 12 14 16 18 20
2 4 6 8 10 12 14 16 18 20
2 4 6 8 10 12 14 16 18 20
2 4 6 8 10 12 14 16 18 20
2 4 6 8 10 12 14 16 18 20




stdout
2 4 6 8 10 12 14 16 18 20 
2 4 6 8 10 12 14 16 18 20 
2 4 6 8 10 12 14 16 18 20 
2 4 6 8 10 12 14 16 18 20 
2 4 6 8 10 12 14 16 18 20 
2 4 6 8 10 12 14 16 18 20 
2 4 6 8 10 12 14 16 18 20 
2 4 6 8 10 12 14 16 18 20 
2 4 6 8 10 12 14 16 18 20 
2 4 6 8 10 12 14 16 18 20