题意是让找回文串,输入的如果是回文串,可以直接输出,如果不是回文串,就把它改成回文串,输出的回文串没有特定的要求,所以我们可以想到直接把输入的字符串倒着再输出一遍就好了,比如输入abc,输出abccba。写法可以直接先输出一遍,然后再倒着输出一遍,当然也可以用reverse函数(字符串反转)。
AC代码:
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
string str;
cin>>str;
cout<<str;
reverse(str.begin(),str.end());
cout<<str<<endl;
return 0;
}