Aleksandr_Grigoryev

29.11.17 40a

Nov 29th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n;
  7.     n = 5;
  8.     int** a = new int*[n];
  9.     for (int i = 0; i < n; i++)
  10.     {
  11.         a[i] = new int[n];
  12.     }
  13.     for (int i = 0; i < n; i++)
  14.     {
  15.         for (int j = 0; j<n; j++)
  16.             if (i == j)
  17.             {
  18.                 a[i][j] = 1;
  19.             }
  20.             else
  21.             {
  22.                 a[i][j] = 0;
  23.             }
  24.     }
  25.     for (int i = 0; i < n; i++)
  26.     {
  27.         for (int j = 0; j < n; j++)
  28.             cout<< a[i][j] << " ";
  29.         cout<< endl;
  30.     }
  31.     delete[]a;
  32.     system("pause");
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment