Advertisement
SelinD

ex18

May 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int a[25][25];
  4. int main()
  5. {
  6. int n,i,j;
  7. cin>>n;
  8. for(i=1; i<=n; i++)
  9. {
  10. for(j=1; j<=n; j++)
  11. {
  12. if(i+j==n+1) a[i][j]=1;
  13. }
  14. }
  15. for(j=1; j<=n; j++)
  16. {
  17. if(j<=3) {a[n+1][j]=1;}
  18. else { a[n+1][j]=0;}
  19. }
  20. for(i=n+2; i<=2*n-2; i++)
  21. {
  22. for(j=1; j<=n; j++) a[i][j]=a[i-1][j-1];
  23. }
  24. for(i=1; i<=2*n-2; i++)
  25. {
  26. for(j=1; j<=n; j++)
  27. cout<<a[i][j]<<" ";
  28. cout<<endl;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement