fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int matriz[3][3] = {{1, 2, 3},
  6. {4, 5, 6},
  7. {7, 8, 9}};
  8.  
  9. int somaP = 0, somaS = 0;
  10.  
  11. for(int i = 0; i < 3; i++)
  12. {
  13. somaP += matriz[i][i];
  14. somaS += matriz[i][2-i];
  15. }
  16.  
  17. cout << somaP << endl << somaS;
  18. return 0;
  19. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
15
15