Laitofai

76

Apr 8th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. // 76
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin >> n;
  10.     int arr[n][n];
  11.     // заполняем нулями
  12.     for(int i = 0; i < n; i++){
  13.         for(int j = 0; j < n; j++){
  14.             arr[i][j] = 0;
  15.         }
  16.     }
  17.  
  18.     // заполняем по красоте
  19.     for(int i = 0; i <= n / 2; i++){
  20.         for(int j = i; j < n - i; j++){
  21.             arr[j][i] = 1;
  22.             arr[j][n - 1 - i] = 1;
  23.         }
  24.     }
  25.  
  26.     // выводим всё
  27.     for(int i = 0; i < n; i++){
  28.         for(int j = 0; j < n; j++){
  29.             cout << arr[i][j] << " ";
  30.         }
  31.         cout << endl;
  32.     }
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment