Guest User

Untitled

a guest
Jul 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. //@eyny@abcde12101
  2. #include<iostream>
  3. #include<cstdio>
  4. #include<cstdlib>
  5. #include<cstring>
  6.  
  7. using namespace std;
  8.  
  9. char ch[1000];
  10. int s;
  11. char c;
  12.  
  13. void prt(int i) {
  14. for ( ; s <= i; s++ )
  15. if ( s == i )
  16. printf ( "\n" );
  17. else printf ( "%c", ch[s] );
  18. }
  19.  
  20. int main() {
  21.  
  22. memset ( ch, 0, sizeof(ch) );
  23. while ( gets ( ch ) )
  24. {
  25. int l = strlen ( ch );
  26. c = ch[l-1]; s = 0;
  27. for ( int i = 0; i < l; i++ )
  28. if ( ch[i] == c )
  29. {
  30. if ( i == s )
  31. s = i+1;
  32. else prt(i);
  33. }
  34. else if ( ch[i] == ' ' )
  35. {
  36. if ( i >= s+1 )
  37. for ( ; s <= i; s++ )
  38. if ( s == i )
  39. printf ( "\n" );
  40. else prt(i);
  41. break;
  42. };
  43. printf ( "\n" );
  44. memset ( ch, 0, sizeof(ch) );
  45. }
  46.  
  47. return 0;
  48.  
  49. }
Add Comment
Please, Sign In to add comment