#include <iostream> using namespace std; int research2(char *str) { int len = strlen(str); if (str == NULL || len < 1) { return 0; } if (len < 2) { return 1; } char *begin; char *end; int count = 0; int maxlen = 0; for (int i = 0; i < len; i++) { for (int j = 0; j < len; j++) { begin = str + i; end = (str + len - 1) - j; count = end - begin + 1; while (*begin == *end&&begin < end) { begin++; end--; } if (end == begin || end < begin) { if (count > maxlen) { maxlen = count; } } } } return maxlen; } void main() { char str[50]; cin >> str; int result = research2(str); cout << result << endl; } </iostream>