力扣C++刷题记录:
1. 回文判断
c++函数reverse();用来将数组、字符串、容器逆序。
需要头文件
#include <algorithm>
class Solution {
public:
bool isPalindrome(int x) {
string t=to_string(x);
reverse(t.begin(),t.end());
return t==to_string(x);
}
};
link.