fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. int m=0;
  7. int c=0;
  8. cin >> n;
  9. int ** x = new int * [n];
  10. for (int i = 0; i < n; i++)
  11. x[i] = new int[n];
  12. for (int i = 0; i < n; i++) {
  13. for (int j = 0; j < n; j++)
  14. cin >> x[i][j];
  15. }
  16. for (int i = 0; i < n; i++){
  17. m+=x[i][i];
  18. c+=x[i][n-1-i];
  19. }
  20. for (int i = 0; i < n; i++)
  21. delete []x[i];
  22. delete []x;
  23. cout << m << " " << c;
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 15232KB
stdin
5
12 32 54 76 12
95 23 21 123 0
65 32 1 773 992
5 32 155 866 912
134 44 74 11 23
stdout
36 136