Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <locale.h>
- #include <iostream>
- #include <string>
- using namespace std;
- bool isPalindrom(string s) {
- for (int i = 0; i < s.size() / 2; i++) {
- if (s[i] != s[s.size() - 1 - i]) {
- return false;
- }
- }
- return true;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int n;
- cout << "Введите число строк" << endl;
- cin >> n;
- string a[10000];
- cout << "Введите строки" << endl;
- rewind(stdin);
- for (int i = 0; i < n; i++) {
- getline(cin, a[i]);
- rewind(stdin);
- }
- for (int i = 0; i < n; i++) {
- if (isPalindrom(a[i])) {
- cout << a[i] << " - палиндром" << endl;
- }
- else cout << a[i] << " - не палиндром" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement