Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
59
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. #include<string>
  3.  
  4. using std::cin;
  5. using std::cout;
  6. using std::string;
  7.  
  8. void capitalize_letters(string & a);
  9.  
  10.  
  11. void main() {
  12. string a;
  13. cout << "Please enter a Word \n";
  14. cin >> a;
  15. std::getline(cin, a);
  16. capitalize_letters(a);
  17. cout << a;
  18.  
  19. bool is_palindrome(true);
  20. for (size_t i(0); is_palindrome && i < a.size() / 2; ++i) {
  21. if (a[i] != a[a.size() - i - 1]) {
  22. is_palindrome = false;
  23. break;
  24. }
  25. }
  26.  
  27. if (is_palindrome) {
  28. cout << "This is a palindrome \n";
  29. }
  30. else {
  31. cout << "This is not a palindrome \n";
  32. }
  33.  
  34. }
  35.  
  36. void capitalize_letters(string & a) {
  37. for (size_t i(0); i < a.size(); ++i) {
  38. a[i] = toupper(a [i]);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement