Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- char s[300];
- cin.getline( s , 300 ) ;
- int lung = strlen ( s ) ;
- int max1 = 1 ;
- char rasp [300] ;
- int i = lung / 2 ;
- char aux [300] , aux2[300] ;
- for ( i = 0 ; i <= lung - 2 ; ++i )
- {
- for ( int j = 2 ; j <= lung - j ; ++j )
- {
- strncpy( aux ,s + i , j ) ;
- aux[j] = NULL ;
- if ( strstr ( s + i + j , aux ) )
- {
- if ( j > max1 )
- {
- max1 = j ;
- strcpy ( rasp , aux );
- }
- else
- {
- if ( j == max1 )
- {
- if ( strcmp ( aux , rasp ) < 0 ) strcpy( rasp , aux ) ;
- }
- }
- }
- }
- }
- cout << rasp ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement