Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- do
- {
- cin >>n;
- if (n<1 || n>100) cout <<"1<=n<=100\n";
- }
- while (n<1 || n>100);
- int **a = new int*[n];
- for (int i = 0; i < n; i++)
- a[i]=new int[n];
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if (i<n-1-j) a[i][j]=0;
- else if (i>n-1-j) a[i][j]=2;
- else a[i][j]=1;
- cout <<a[i][j]<<" ";
- }
- cout <<endl;
- }
- for (int i = 0; i < n; i++)
- delete [] a[i];
- delete [] a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement