20 程序题 10分 输入一个长度不超过30的字符串存放在s数组中将s中字符串的反序和正序进行连接形成一个新串存放在t数组中最后输出t中的字符串。例如输入ABCD则应输出DCBAABCD注意:语言选DEV C++。
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char s[31], t[61];
cin >> s;
int len = strlen(s);
for (int i = 0; i < len; i++) {
t[i] = s[len - i - 1];
}
for (int i = 0; i < len; i++) {
t[i + len] = s[i];
}
t[2 * len] = '\0';
cout << t << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/dJcx 著作权归作者所有。请勿转载和采集!