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