1 条题解

  • 0
    @ 2025-8-7 12:28:08

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

    • 使用 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;
    }
    

    信息

    ID
    50
    时间
    1000ms
    内存
    256MiB
    难度
    3
    标签
    递交数
    2
    已通过
    2
    上传者