Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE 100000
- int main(void)
- {
- char s[SIZE] = {0};
- gets(s);
- char subs[SIZE] = "-1\0";
- int cb = 0, ce = 0;
- int ab = 0, ae = 0;
- for (int i = 0; i < SIZE && s[i]; ++i){
- cb = i;
- ce = i;
- for (int j = i+1; j < SIZE && s[j]; ++j)
- {
- if (s[i] == s[j]){
- for (int k = 0; k < (j-i)/2; ++k){
- if ( s[i+k] != s[j-k]){
- ce = j;
- }
- }
- }
- else{
- ce = j;
- }
- }
- if ( (ae - ab) < ( ce - cb))
- {
- ae = ce;
- ab = cb;
- }
- }
- if ((ae-ab) > 1){
- for (int i = ab ; i <= ae; ++i)
- subs[i-ab] = s[i];
- subs[ae-ab+1] = 0;
- }
- printf("%s", subs);
- fflush(stdin);
- getc(stdin);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement