Advertisement
J00ker

\.

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