This commit is contained in:
2026-01-28 15:56:45 +03:00
parent 8bdba1f2f2
commit 3907f75973
11 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#include <algorithm>
#include <iostream>
#include <string>
class Solution {
public:
bool isPalindrome(int x) {
std::string s = std::to_string(x);
std::string reversed_s = s;
std::reverse(reversed_s.begin(), reversed_s.end());
return s == reversed_s;
}
};
int main (int argc, char *argv[]) {
Solution s;
int test[] = {121, -121, 10};
for (int t : test) {
std::cout << "isPalindrome(" << t << ") = " << s.isPalindrome(t) << std::endl;
}
return 0;
}