Advertisement
Saleh127

Untitled

Apr 23rd, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,a[100][100],b,c,d=0,i,j,k,l,r;
  6. cin>>n;
  7. for(i=0;i<2*n-1;i++)
  8. {
  9. for(r=0;r<=i && r<n;r++)
  10. {
  11. c=i-r;
  12. if(c>=0 && c<n)
  13. {
  14. a[r][c]=++d;
  15. }
  16. }
  17. }
  18. for(i=0;i<n;i++)
  19. {
  20. for(j=n-1;j>=0;j--)
  21. {
  22. printf("%d ",a[i][j]);
  23. }
  24. printf("\n");
  25. }
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement