Advertisement
Cati29

89

Jan 26th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int Pal(char s[])
  5. {
  6. int n,i,j;
  7. n= strlen(s);
  8. i=0;j=n-1;
  9. while(i< j)
  10. {
  11. if(s[i]!=s[j])
  12. return 0;
  13.  
  14. else
  15. {
  16. i++;
  17. j--;
  18. }
  19. }
  20. return 1;
  21. }
  22. char s[300], t[300], *p;
  23. int main()
  24. {
  25. int k = 0,i,n;
  26. cin>>n;
  27. cin.get();
  28. for(i = 1; i <= n; i++)
  29. {
  30. cin.getline(s, 100);
  31. for(i = 0; s[i]; i++)
  32. {
  33. if(s[i]!= ' ')
  34. t[k++]=s[i];
  35. }
  36. t[k++]=NULL;
  37. if(Pal(t)==1) cout << "1"<< "\n";
  38. else cout << "0" << "\n";
  39. }
  40.  
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement