Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5. using namespace std;
  6.  
  7. bool palindrom(string x)
  8. {
  9. int d = x.size();
  10. int left = 0;
  11. int right = d - 1;
  12. while (left < right)
  13. {
  14. if (x[left] != x[right])
  15. {
  16. return false;
  17. break;
  18. }
  19. else
  20. {
  21. left++;
  22. right--;
  23. }
  24. }
  25. return true;
  26. }
  27. int main()
  28. {
  29. string x;
  30. cout << "Podaj liczbę =";
  31. cin >> x;
  32. if(palindrom(x)cout << "\nLiczba" <<x<< " jest palindromem\n" ;
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement