#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
//对称有两种情况,1是无对称轴数,如1221,2是有对称轴数,如13231
//给出思路,用to_string将int变为字符串,随后用reverse反转,然后比较反转前后的字符串
int main() {
for(int n=1;n<=256;n++)
{
int p=n*n;
string str=to_string(p);
string c=str;
reverse(str.begin(),str.end());
if(c==str)
cout<<n<<endl;
}
}
// 64 位输出请用 printf("%lld")
会用reverse(it,it)就简单

京公网安备 11010502036488号