/
lyapdy
/
Object_oriented_programming_cpp_318
Обзор
Документация
Войти
/
lyapdy
/
Object_oriented_programming_cpp_318
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lab6/task_2.cpp
47 строк
1 KB
danillyapunov
lab6commit
10 янв 2026, 15:23
10 янв 2026, 15:23
b29f1a0
Код
Авторство
О чём код?
#include <iostream> #include <string> #include <algorithm> #include <cctype> #include "task_2.h" bool PalindromeChecker::is_palindrome(const std::string& input) { std::string cleaned_input; for (char ch : input) { if (!std::isspace(ch)) { cleaned_input += std::tolower(ch); } } int left = 0; int right = cleaned_input.size() - 1; while (left <= right) { if (cleaned_input[left++] != cleaned_input[right--]) { return false; } } return true; } void PalindromeCheckerRunner::run() { PalindromeChecker checker; std::string input; do { std::cout << "Введите строку длиной до 17 символов ('q' для выхода): "; std::getline(std::cin, input); if (input.length() > 17 && input != "q") { std::cout << "Ошибка: Длина строки превышает лимит в 17 символов.\n"; continue; } if (input == "q") break; if (checker.is_palindrome(input)) { std::cout << "'" << input << "' - это палиндром!\n"; } else { std::cout << "'" << input << "' - это НЕ палиндром.\n"; } } while (true); }