题解
【入门】回文字符串
1 条题解
-
0
#include <bits/stdc++.h> using namespace std; int main() { stack<char>s; int n; string t; cin>>n; cin>>t; for(int i=0;i<n;i++){ s.push(t[i]);//存入字符串 } for(int i=0;i<n/2;i++){//循环前一半 if(t[i]!=s.top()){//对称位置不相等 cout<<"No"; return 0; }else{//继续判断下一行对称位置 s.pop(); } } cout<<"Yes"; return 0; }
- 1