forked from itsprueba/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwaveprint.cpp
More file actions
61 lines (51 loc) · 1011 Bytes
/
waveprint.cpp
File metadata and controls
61 lines (51 loc) · 1011 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
void solve()
{
int arr[100][100];
int m,n;
m=4;
n=4;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
cin>>arr[i][j];
}
}
vector<int> res;
int startRow=0;
int endRow=m-1;
int startCol=0;
int endCol=n-1;
while(endCol>=0)
{
for(int i=startRow;i<=endRow;i++)
{
res.push_back(arr[i][endCol]);
}
endCol=endCol-1;
for(int j=endRow;j>=startRow;j--)
{
res.push_back(arr[j][endCol]);
}
endCol=endCol-1;
}
for(int i=0;i<res.size();i++)
{
cout<<res[i]<<" ";
}
//1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int tt;
// cin>>tt;
// while(tt--)
solve();
return 0;
}