Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. /*
  2. Write a program that finds if a string is a palindrome.
  3. */
  4.  
  5. #include <iostream>
  6. #include <string>
  7.  
  8. using namespace std;
  9.  
  10. void palindromeFind(string myString)
  11. {
  12. string backwards;
  13.  
  14. for (int i = myString.length() - 1; i < myString.length(); i--)
  15. {
  16. backwards = backwards + myString[i];
  17. }
  18. if (backwards == myString)
  19. cout << "palindrome";
  20. else
  21. cout << "not a plaindrome";
  22. }
  23.  
  24.  
  25. int main()
  26. {
  27. string x;
  28. getline(cin, x);
  29.  
  30. palindromeFind(x);
  31.  
  32.  
  33.  
  34. cin.get();
  35. cin.get();
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement