forked from VibhutiJindal/CodeChef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtopo.cpp
More file actions
37 lines (30 loc) · 698 Bytes
/
topo.cpp
File metadata and controls
37 lines (30 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
using namespace std;
int main()
{
int m=0,n=0;
cin>>m>>n;
int a[m][n];
int val=1;
for(int row=0;row<m;row++){
for(int col=0;col<n;col++){
a[row][col]=val;
val++;
cout<<a[row][col]<<" ";
}
cout<<endl;
}
for(int col=0;col<n;col++){
if(col%2==0){
for(int row=0;row<m;row++){
cout<<a[row][col]<<" ";
}
}
else{
for(int row=m-1;row>=0;row--){
cout<<a[row][col]<<" ";
}
}
}
return 0;
}