Advertisement
elephantsarecool

zmeyka

Jan 18th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,i;
  6.     cin>>n;
  7.     for(i=0;i<n-n%2;i+=2)
  8.     {
  9.         for(int j=1;j<=n;++j)
  10.             cout<<j+i*n<<' ';
  11.         cout<<endl;
  12.         for(int j=n;j>=1;--j)
  13.             cout<<j+(i+1)*n<<' ';
  14.         cout<<endl;
  15.     }
  16.     if(n%2)
  17.         for(int j=1;j<=n;++j)
  18.             cout<<j+i*n<<' ';
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement