Advertisement
VictoriaLodochkina

lab 8 z1 it's more than

Nov 18th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     using namespace std;
  6.     int n;
  7.     cout << "Enter n: " << endl;
  8.     cin >> n;
  9.     double** mas = new double*[n];
  10.     for (int i = 0; i < n; i++)
  11.         mas[i] = new double[n];
  12.     for (int i = 0; i < n; i++)
  13.         for (int j = 0; j < n; j++)
  14.             mas[i][j]=0;
  15.     double sum = 0;
  16.     double sum2 = -mas[0][0];
  17.     for (int i = 0; i < n; i++)
  18.     {
  19.         cout << endl;
  20.         for (int j = 0; j < n; j++)
  21.         {
  22.             cout << mas[i][j] << " ";
  23.         }
  24.     }
  25.     cout << endl;
  26.     for (int i = 0; i < n; i++)
  27.     {
  28.         for (int j = 0; j < n; j++)
  29.         {if (((i<=j/2)&&(j>=n/2)&&(j-i>=n/2))||((i>=n/2)&&(j>=n/2)&&(j-n+i+1>=n/2)))
  30.             mas[j][i] = 1;
  31.         }
  32.     }
  33.     for (int i = 0; i < n; i++)
  34.     {
  35.         cout << endl;
  36.         for (int j = 0; j < n; j++)
  37.         {
  38.             cout << mas[i][j] << " ";
  39.         }
  40.     }
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement