Advertisement
Dizzy3113

Untitled

Jan 13th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int a[101][101], i, j, n, nr=1, nr2;
  8. cin>>n;
  9. nr2=n;
  10.  
  11.  
  12.  
  13. for(i=1; i<=n; i++)
  14. {
  15. nr=1;
  16. nr2=n;
  17. for(j=1; j<=n; j++)
  18. {
  19. if(i%2==1)
  20. {
  21. a[i][j]=nr;
  22. nr++;
  23. }
  24. if(i%2==0)
  25. {
  26. a[i][j]=nr2;
  27. nr2--;
  28. }
  29. }
  30. }
  31.  
  32.  
  33.  
  34.  
  35. for(i=1; i<=n; i++)
  36. {
  37. for(j=1; j<=n; j++)
  38. cout<<a[i][j]<<" ";
  39. cout<<endl;
  40. }
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement