-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04_Array_22.cpp
More file actions
41 lines (41 loc) · 928 Bytes
/
Copy path04_Array_22.cpp
File metadata and controls
41 lines (41 loc) · 928 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
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
string input[n], ans[n];
for(int i=0;i<n;i++){
cin >> input[i];
ans[i]=input[i];
}
cin.ignore();
string order;
getline(cin,order);
for(int i=0;i<order.size();i++){
if(order[i]=='C'){
for(int j=0;j<n/2;j++){
ans[j]=input[j+(n/2)];
ans[j+(n/2)]=input[j];
}
}
if(order[i]=='S'){
int offset = (n/2)-1;
for(int j=0;j<n;j++){
if(j%2==0){
ans[j]=input[j/2];
}
else{
ans[j]=input[j+offset];
offset--;
}
}
}
for(int j=0;j<n;j++){
input[j]=ans[j];
}
}
for(int i=0;i<n;i++){
cout << ans[i] << " ";
}
return 0;
}