Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@eyny@abcde12101
- #include<iostream>
- #include<cstdio>
- #include<cstdlib>
- #include<cstring>
- using namespace std;
- char ch[1000];
- int s;
- char c;
- void prt(int i) {
- for ( ; s <= i; s++ )
- if ( s == i )
- printf ( "\n" );
- else printf ( "%c", ch[s] );
- }
- int main() {
- memset ( ch, 0, sizeof(ch) );
- while ( gets ( ch ) )
- {
- int l = strlen ( ch );
- c = ch[l-1]; s = 0;
- for ( int i = 0; i < l; i++ )
- if ( ch[i] == c )
- {
- if ( i == s )
- s = i+1;
- else prt(i);
- }
- else if ( ch[i] == ' ' )
- {
- if ( i >= s+1 )
- for ( ; s <= i; s++ )
- if ( s == i )
- printf ( "\n" );
- else prt(i);
- break;
- };
- printf ( "\n" );
- memset ( ch, 0, sizeof(ch) );
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment