Advertisement
SergeyPGUTI

8.2.3

Feb 18th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8.  
  9.  
  10. int main()
  11. {
  12.     int n;
  13.     cin>>n;
  14.     int ** p= new int*[n];
  15.  
  16.     for (int i=0;i<n;i++)
  17.     {
  18.         p[i]=new int[n];
  19.     }
  20.  
  21.     for(int i=0;i<n;i++)
  22.     {
  23.         p[i][n-i-1]=1;
  24.  
  25.         for(int j=0;j<n-i-1;j++)
  26.             p[i][j]=0;
  27.  
  28.         for(int j=n-i;j<n;j++)
  29.             p[i][j]=2;
  30.     }
  31.  
  32.  
  33.     //вывод p
  34.     for (int i=0;i<n;i++)
  35.     {
  36.  
  37.         for (int j=0;j<n;j++)
  38.             {
  39.                 cout<<p[i][j]<<" ";
  40.             }
  41.             cout<<endl;
  42.     }
  43.  
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement