题目描述:
打印所有不超过n(n<256)的,其平方具有对称性质的数。
如11*11=121
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <stack>
using namespace std;
bool isDuichen(string s) {
string t = s;
reverse(t.begin(), t.end());
if ( t == s) {
return true;
}
return false;
}
string toString(int n) {
char temp[5];
itoa(n, temp, 10);
string s(temp);
return s;
}
int main() {
int n;
cin >> n;
for (int i = 0; i <= n; i++) {
if (isDuichen(toString(i * i))) {
cout << i << endl;
}
}
}