#include <iostream>
#include <string>
using namespace std;
int s(int x)
{
string s = to_string(x);
if (s.length() == 2)
{
if (s[0] == s[1])
return 1;
}
else
{
for (int i = 0; i < s.length(); i++)
{
if (s[i] != s[s.length() - i - 1 ])
{
return 0;
}
}
return 1;
}
}
int main() {
for (int i = 11; i <= 999; i++)
{
if (s(i) && s(i * i) && s(i * i * i))
cout << i << endl;
}
return 0;
}
输出11-999中的三重回文数
![](https://img-home.csdnimg.cn/images/20240711042549.png)