Advertisement
Guest User

untitled

a guest
May 19th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main() {
  5. string s, longest, current;
  6. getline(cin, s);
  7. int pos;
  8. pos = 0;
  9. longest = s.substr(0, s.find(" ", pos));
  10. while (s.find(" ", pos + 1) != -1) {
  11. current = "";
  12. current = s.substr(pos, s.find(" ", pos) - pos);
  13.  
  14. if (longest.size() < current.size()) {
  15. longest = current;
  16. }
  17. pos += current.size() + 1;
  18. cout << current << pos << endl;
  19. }
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement