Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "RU");
- char line[] = "Тимур играет в бравлстарс азаза тимумит";
- cout << line << endl << endl;
- int max = 0, s = 0, max_i;
- for (int i = 0; i < strlen(line); i++)
- {
- if (line[i] == ' ')
- {
- if (s > 0) {
- bool isLoop = true;
- for (int j = i - s; j < i; j++) {
- cout << line[i - j - 1] << " " << line[j] << endl;
- if (line[i - j - 1] != line[j]) {
- isLoop = false;
- }
- }
- if (isLoop) {
- if (s > max)
- {
- max = s;
- max_i = i - s + 1;
- }
- }
- }
- s = 0;
- }
- else {
- s++;
- }
- }
- if (max > 0) {
- for (int i = max_i; i < max + max_i; i++) {
- cout << line[i];
- }
- }
- else {
- cout << "Палиндромов нет" << endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement