fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. bool check(string s, int l, int r){
  6. if(l >= r) return true;
  7. if(s[l] != s[r]) return false;
  8. return check(s, l+1, r-1);
  9. }
  10.  
  11. int main(){
  12. string s;
  13. cin >> s;
  14. int n = s.size();
  15. if(check(s, 0, n-1)){
  16. cout << "YES";
  17. }
  18. else cout << "NO";
  19. }
  20.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
YES