-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathams.cpp
102 lines (100 loc) · 2.7 KB
/
ams.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
string cop(char e[])
{
string s;
int i = 0;
while(e[i] != '\0') {
s[i] = e[i];
i++;
}
return s;
}
int check(int a,int u[10],int n)
{
vector<int> pt;
vector<int> :: iterator it;
while(a >= 10) {
pt.push_back(a%10);
a /= 10;
}
pt.push_back(a);
for(it = pt.end()-1;it >= pt.begin();it--) {
u[n] = (*it);
n++;
}
return n;
}
int main()
{
while(!cin.eof()) {
int s,n;
string r;
int u[15];
cin >> s >> r;
n = check(s,u,0);
int a[15] = {0};
char ch[n+1][252];
int i = 0;
int temp = r.length();
int k = 0;
int flag = 1;
while(flag) {
if(k%2 == 0) {
for(int p = 0;p < n;p++) {
if(p%2 == 0) {
for(int y = i;y < i+2;y++) {
if(y < temp) {
ch[u[p]][a[u[p]]] = r[y];
a[u[p]]++;
}else {
flag = 0;
}
}
i += 2;
}else if(p%2 != 0 ){
if(i < temp) {
ch[u[p]][a[u[p]]] = r[i];
i++;
a[u[p]]++;
}else {
flag = 0;
}
}
}
}else {
for(int p = 0;p < n;p++) {
if(p%2 == 0 ) {
if(i < temp) {
ch[u[p]][a[u[p]]] = r[i];
i++;
a[u[p]]++;
}else {
flag = 0;
}
}else if(p%2 != 0){
for(int y = i;y < i+2;y++) {
if(y < temp) {
ch[u[p]][a[u[p]]] = r[y];
a[u[p]]++;
}else {
flag = 0;
}
}
i += 2;
}
}
}
k++;
}
for(int j = 1;j <= n;j++) {
for(int k = 0;k < a[j];k++) {
cout << ch[j][k];
}
}
cout << endl;
}
return 0;
}