You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
using namespace std;
|
|
|
|
|
const int N = 210;
|
|
|
|
|
|
|
|
|
|
int p[N];
|
|
|
|
|
char s[N], t[N];
|
|
|
|
|
int main() {
|
|
|
|
|
int n;
|
|
|
|
|
cin >> n;
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
int x;
|
|
|
|
|
cin >> x; // 输入的是 4 1 2 3 ,映射成: 3 0 1 2,改成下标从0开始,方便后续计算
|
|
|
|
|
p[i] = x - 1;
|
|
|
|
|
}
|
|
|
|
|
while (true) {
|
|
|
|
|
int m;
|
|
|
|
|
cin >> m;
|
|
|
|
|
if (m == 0) break;
|
|
|
|
|
|
|
|
|
|
cin >> s; // cin输入字符数组,与string没什么区别
|
|
|
|
|
// 补空格
|
|
|
|
|
for (int i = strlen(s); i < n; i++) s[i] = ' ';
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i <= m; i++) { // 加密m次
|
|
|
|
|
for (int j = 0; j < n; j++) // 每个字符
|
|
|
|
|
t[p[j]] = s[j]; // 替换
|
|
|
|
|
memcpy(s, t, sizeof t); // 还原为s
|
|
|
|
|
}
|
|
|
|
|
cout << s << endl;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|