Advertisement
STANAANDREY

matrix areas

Jun 21st, 2022
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int n = 5;
  4. char a[n][n];
  5.  
  6. int main() {
  7.  
  8.     for (int i = 0; i < n; i++) {
  9.         for (int j = 0; j < n; j++) {
  10.             a[i][j] = '*';
  11.         }
  12.     }
  13.  
  14.     for (int i = 0; i < n; i++) {
  15.         for (int j = 0; j < n; j++) {
  16.             if (i < j && i + j + 1 < n) a[i][j] = 'n';
  17.             if (i < j && i + j + 1 > n) a[i][j] = 'e';
  18.             if (i > j && i + j + 1 > n) a[i][j] = 's';
  19.             if (i > j && i + j + 1 < n) a[i][j] = 'w';
  20.         }
  21.     }
  22.  
  23.     for (int i = 0; i < n; i++) {
  24.         for (int j = 0; j < n; j++) {
  25.             cout << a[i][j] << ' ';
  26.         }
  27.         cout << endl;
  28.     }
  29.  
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement