Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Constructii in memorie
- ///n=5; 1 2 3 4 5/2 3 4 5 4/3 4 5 4 3/4 5 4 3 2/5 4 3 2 1
- #include <iostream>
- using namespace std;
- int main()
- {
- int a[100][100],n,i,j,aux;
- cout<<"n=";
- cin>>n;
- for(i=1;i<=n;i++)
- for(j=1;j<=n+1-i;j++)
- if(i+j<n+1)
- {
- a[i][j]=i+j-1;
- a[n-i+1][n-j+1]=i+j-1;
- }
- else
- if(i+j==n+1)
- a[i][j]=n;
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- cout<<a[i][j]<<' ';
- cout<<endl;
- }
- cout<<endl<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement