知识点:模拟
20分钟过了,这道题我的思路就是第一个序列翻转一下,然后第二个序列的前面补上第一个序列长度的空格,接下来走几步,就让第一个序列前面补几个空格,表示他从左往右走了几步,接下来就是输出,下标是两人共用的,首先要注意一下范围的问题,然后就是同一个下标,两个序列都是字母的话,先输出第二个序列的,再输出第一个序列的,这个自己画一下就这知道了,总之代码好写,几分钟完事儿,但是思路想了十分钟,
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
string s1, s2;
cin >> s1 >> s2;
reverse(s1.begin(), s1.end());
for (int i = 0; i < (int) s1.size(); i++) {
s2.insert(0, " ");
}
int t;
cin >> t;
while (t--) s1.insert(0, " ");
int t1 = (int) s1.size(), t2 = (int) s2.size();
for (int i = 0; i < max(t1, t2); i++) {
if (i < t1 && i < t2) {
if (s2[i] != ' ') cout << s2[i];
if (s1[i] != ' ') cout << s1[i];
} else if (i < t1 && i >= t2) {
if (s1[i] != ' ') cout << s1[i];
} else {
if (s2[i] != ' ') cout << s2[i];
}
}
return 0;
}