Advertisement
LEGEND2004

F

Nov 18th, 2023
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. int n;
  2. cin >> n;
  3. int a[n + 5][n + 5];
  4. int x = 1;
  5. for(int i = 1; i <= n; i++){
  6.     if(i % 2 != 0){
  7.         for(int j = 1; j <= n; j++){
  8.             a[i][j] = x;
  9.             x++;
  10.         }
  11.     }else{
  12.         for(int j = n; j >= 1; j--){
  13.             a[i][j] = x;
  14.             x++;
  15.         }
  16.     }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement