使用以下函数模拟比较过程即可:

  • 使用 std::stringstreamsprintf(但不能用 itoa)将数字转换为字符串。
  • 使用 std::reversestrrev 反转字符串。
  • 使用 operator == (std::string a, std::string b)strcmp 进行比较。
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long s, e;
    cin >> s >> e;
    stringstream v;
    for (long long i = s; i <= e; i++)
    {
        v << i << endl;
        string y, z;
        v >> y;
        z = y;
        reverse(z.begin(), z.end());
        if (z == y) puts("Palindrome!");
        else printf("%lld\n", i);
    }
    return 0;
}