Advertisement
alfps

Untitled

Jul 19th, 2020
1,003
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <algorithm>
  2. using   std::max;
  3.  
  4. #include <iostream>
  5. using   std::cin, std::cout, std::endl;
  6.  
  7. #include <string>
  8. using   std::getline, std::string;
  9.  
  10. auto input()
  11.     -> string
  12. {
  13.     string s;
  14.     getline( cin, s );
  15.     return s;
  16. }
  17.  
  18. auto main()
  19.     -> int
  20. {
  21.     const string s          = input();
  22.     cout << s << endl;
  23.  
  24.     const int len           = int( s.length() );
  25.     const int shortening    = (len >= 10 and s[9] == 'w'? 32 : 17);
  26.     const int new_len       = max( 0, len - shortening );
  27.     const int new_start     = len - new_len;
  28.     cout << endl;
  29.     cout << s.substr( new_start, new_len ) << endl;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement