Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int n,i,j,a[25][25],k=1;
- cin>>n;
- for(i=1;i<=n;i++)
- {
- if(i%2!=0)
- {
- for(j=1;j<=n;j++)
- {
- a[i][j]=k;
- k++;
- }
- }
- else
- {
- for(j=n;j>=1;j--)
- {
- a[i][j]=k;
- k++;
- }
- }
- }
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- cout<<a[i][j]<<" ";
- cout<<endl;
- }
- }
Add Comment
Please, Sign In to add comment