-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13.TOANDFRO.cpp
65 lines (56 loc) · 1.26 KB
/
13.TOANDFRO.cpp
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
62
63
64
#include<bits/stdc++.h>
using namespace std;
#define max2(a, b) (((a) > (b)) ? (a) : (b))
#define min2(a, b) (((a) > (b)) ? (b) : (a))
#define abs(a) (((a) > 0) ? (a) : (-(a)))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
const int INF = 0x3f3f3f3f;
typedef long long ll;
int main()
{
int n;
cin>>n;
while(n)
{
string s;
cin>>s;
int len = s.length();
int row = len / n;
int col = n;
char arr[row][col];
bool flag = true;
int holder = 0;
for(int i = 0; i < row; i++)
{
if(flag)
{
for(int j = 0; j < col; j++)
{
arr[i][j] = s[holder];
holder++;
}
flag = false;
}
else
{
for(int j = col - 1; j >= 0; j--)
{
arr[i][j] = s[holder];
holder++;
}
flag = true;
}
}
for(int j = 0; j < col; j++)
{
for(int i = 0; i < row; i++)
{
cout<<arr[i][j];
}
}
cout<<endl;
cin>>n;
}
return 0;
}