Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. ///Constructii in memorie
  2. ///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
  3. #include <iostream>
  4. using namespace std;
  5. int main()
  6. {
  7. int a[100][100],n,i,j,aux;
  8. cout<<"n=";
  9. cin>>n;
  10. for(i=1;i<=n;i++)
  11. for(j=1;j<=n+1-i;j++)
  12. if(i+j<n+1)
  13. {
  14. a[i][j]=i+j-1;
  15. a[n-i+1][n-j+1]=i+j-1;
  16. }
  17. else
  18. if(i+j==n+1)
  19. a[i][j]=n;
  20. for(i=1;i<=n;i++)
  21. {
  22. for(j=1;j<=n;j++)
  23. cout<<a[i][j]<<' ';
  24. cout<<endl;
  25. }
  26. cout<<endl<<endl;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement