:将字符串b拼接到字符串a,并倒序输出拼接后的结果。
样例输入:
happy
everyday
样例输出:
yadyreveyppah
#include
using namespace std;
int main(){
string a,b;
a=a+b;
char n[1001]=a;
for(int i=a.strlen();i>=0;i--){
cout<<a[i];
}
return 0;
}
拿错了?
char n[1001]=a//是什么鬼?把一个类赋值给char数组,用strcpy(c,a.c_str());
起始值i是字符串长度,
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
using namespace std;
int main()
{
string a, b;
cin >> a >> b;
a += b;
reverse(a.begin(), a.end());
cout << a << endl;
return 0;
}