fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. //#define DEBUG;
  7.  
  8. const unsigned int rows = 5;
  9. const unsigned int columns = 5;
  10.  
  11. int ary[rows][columns];
  12.  
  13. int main() {
  14.  
  15. for (int i = 0; i < rows; i++) {
  16. for (int j = 0; j < columns; j++) {
  17. ary[i][j] = (i + 1) * 10 + (j + 1);
  18. }
  19. }
  20. for (int i = 0; i < rows; i++) {
  21. for (int j = 0; j < columns; j++) {
  22. cout << setw(4) << ary[i][j];
  23. }
  24. cout << endl;
  25. }
  26.  
  27. //cout << SUM;
  28. int temp = 1;
  29. int counter = 0;
  30. for (int j = 1; j < columns; j++) {
  31. #ifdef DEBUG;
  32. cout << "----------\n";
  33. #endif
  34. for (int i = rows-1; i > rows-1-temp; i--) {
  35. #ifdef DEBUG;
  36. cout << ary[j][i] << "\n";
  37. #endif
  38. counter += ary[j][i];
  39. }
  40. temp++;
  41. }
  42.  
  43. cout << "Сумма елементів нижче не головної діагоналі = " << counter;
  44. return 0;
  45. }
  46.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
  11  12  13  14  15
  21  22  23  24  25
  31  32  33  34  35
  41  42  43  44  45
  51  52  53  54  55
Сумма елементів нижче не головної діагоналі = 440