fork download
  1.  
  2. #include <iostream>
  3. #include<bits/stdc++.h>
  4.  
  5. using namespace std;
  6. bool ispald(string s,int l, int r)
  7. {
  8. if(l>=r)
  9. return true;
  10. else
  11. if(s[l]!=s[r])
  12. return 0;
  13. else return ispald(s,l+1,r-1);
  14. }
  15. int main()
  16. {
  17. string str="aabaa";
  18. cout<<ispald(str,0,4);
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5480KB
stdin
45
stdout
1