Advertisement
zeushere

whether palindrome

Apr 18th, 2019
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <time.h>
  4. #include <math.h>
  5. #include <string>
  6.  
  7. using namespace std;
  8. void palindrome(string,int);
  9. int roz=0;
  10. string s1;
  11.  
  12.  
  13. int main(){
  14. srand(time(0));
  15.  
  16. getline(cin,s1);
  17.  
  18. roz=s1.size();
  19. cout<<endl;
  20.  
  21. palindrome(s1,roz);
  22.  
  23.  
  24. return 0;
  25. }
  26.  
  27. void palindrome(string s,int r)
  28. {
  29.  string reversee=s;;
  30.  for(int i=0,j=r-1;i<roz;i++,j--)
  31.  {
  32.      reversee[j]=s[i];
  33.  }
  34.  if((s1.compare(reversee))==0)
  35.  {
  36.      cout<<"Palindrome!";
  37.  }
  38.  else {cout<<"Not Palindrome";}
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement