Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define NMAX 1'000
- int n, arr[NMAX][NMAX];
- void read() {
- cin >> n;
- for (int i = 1; i <= n; i++) {
- for (int j = 1; j <= n; j++) {
- cin >> arr[i][j];
- }
- }
- }
- void getSum() {
- int sum = 0;
- for (int i = 2; i < n; i++) {
- int j = n - 1;
- while (true) {
- if (i <= (n + 1) / 2) {
- if (j == n - i + 1) {
- break;
- }
- } else {
- if (i == j) {
- break;
- }
- }
- sum += arr[i][j];
- j--;
- }
- }
- cout << sum << endl;
- }
- int main() {
- read();
- getSum();
- return 0;
- }
Add Comment
Please, Sign In to add comment