Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string check_current_word(string last_long_word, string next_long_word) {
- if (next_long_word.length() > last_long_word.length() || last_long_word.empty()) {
- last_long_word = next_long_word;
- }
- return last_long_word;
- }
- int task6() {
- string s, current_long_word, last_long_word;
- getline(cin, s);
- for (int i = 0; i < s.length(); i++) {
- if (s[i] != ' ') {
- current_long_word.push_back(s[i]);
- }
- if (s[i] == ' ' || i == s.length() - 1) {
- last_long_word = check_current_word(last_long_word, current_long_word);
- current_long_word.clear();
- }
- }
- cout << last_long_word;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement