Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- bool palindrom(string str)
- {
- for (int i = 0; i<str.length() / 2; i++)
- if (str[i] != str[str.size() - 1 - i])
- return false;
- return true;
- }
- int main()
- {
- string s, word;
- cout << "S = ";
- getline(cin, s);
- int k = 0;
- int i = 0;
- while (i<s.length())
- {
- if ((s[i]) >= 'a' && s[i] <= 'z')
- {
- word = "";
- while (i<s.length() &&((s[i]) >= 'a' && s[i] <= 'z'))
- {
- word.append(1,s[i]);
- ++i;
- }
- if (palindrom(word))
- k++;
- }
- else ++i;
- }
- cout << "kol-vo=" << k;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment