Advertisement
hadiuzzaman65

string palindrome or not

Apr 13th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.    string s;
  8.    cin>>s;
  9.    int n=s.size();
  10.    int low=0;
  11.    int high=n-1;
  12.  
  13.    while(low<high)
  14.    {
  15.        if(s[low++] !=s[high--])
  16.        {
  17.            cout<< "string is not palindrome.";
  18.            return 0;
  19.        }
  20.    }
  21.     cout<< "string is palindrome";
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement