题解 | #对称平方数1#
对称平方数1
https://www.nowcoder.com/practice/a84d46d5321f4e20931cb725e6c74fad
#include <iostream> #include <string> using namespace std; //判断字符串是否对称 bool check(string s) { bool flag = true; int len = s.length(); for (int i = 0, j = len - 1; i <= j; i++, j--) { if (s[i] != s[j]) flag = false; } return flag; } int main() { for (int i = 0; i < 256; i++) { int pow = i * i; string str = to_string(pow); if (check(str)) cout << i << endl; } return 0; } // 64 位输出请用 printf("%lld")