Best_Project

Palindrome String

Jun 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include<string.h>
  3. #include<string>
  4. using namespace std;
  5.  
  6. bool Check(string str,int s,int length)
  7. {
  8.     if(length < s) return true;
  9.     if(str[s] == str[length-1]) return Check(str,s+1,length-1);
  10.    
  11.     return false;
  12. }
  13. int main() {
  14.     //code
  15.     int t;
  16.     cin>>t;
  17.     while(t--)
  18.     {
  19.         int dodai;
  20.         cin>>dodai;
  21.         string str;
  22.         cin>>str;
  23.         Check(str,0,dodai) ? cout<<"Yes\n": cout<<"No\n";
  24.     }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment