- P50's solution
P50's Solution
- 2025-9-4 21:59:42 @
使用以下函数模拟比较过程即可:
- 使用
std::stringstream
或sprintf
(但不能用itoa
)将数字转换为字符串。 - 使用
std::reverse
或strrev
反转字符串。 - 使用
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;
}