题解 两种做法
2026-08-15 01:30:51
发布于:广东
4阅读
0回复
0点赞
#include<iostream>
#include<algorithm>
using namespace std;
// 完成回文数判定 is_pal 函数
bool is_pal(string s){
string c=s;
reverse(s.begin(),s.end());
return s==c;
}
int main() {
string s;
cin>>s;
if(is_pal(s)) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}
//官方做法
/*
#include<iostream>
using namespace std;
// 完成回文数判定 is_pal 函数
bool is_pal(int n){
int k=0,m=n;
while(n){
k=k*10+n%10;
n/=10;
}
return m==k;
}
int main() {
int n;
cin >> n;
if(is_pal(n)) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}
*/
这里空空如也







有帮助,赞一个