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