Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- bool palindrom(string x)
- {
- int d = x.size();
- int left = 0;
- int right = d - 1;
- while (left < right)
- {
- if (x[left] != x[right])
- {
- return false;
- break;
- }
- else
- {
- left++;
- right--;
- }
- }
- return true;
- }
- int main()
- {
- string x;
- cout << "Podaj liczbę =";
- cin >> x;
- if(palindrom(x)cout << "\nLiczba" <<x<< " jest palindromem\n" ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement