Advertisement
TwITe

Untitled

Aug 9th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. //goo.gl/jJbyJf
  2. int task6() {
  3.     string s, next_long_word, last_long_word;
  4.     int count = 1;
  5.     getline(cin, s);
  6.     //cout << s;
  7.     for (int i = 0; i < s.length(); i++) {
  8.         if (s[i] != ' ') {
  9.             next_long_word.push_back(s[i]);
  10.         }
  11.         if (s[i] == ' ' || i == s.length() - 1) {
  12.             if (next_long_word.length() > last_long_word.length() || last_long_word.empty()) {
  13.                 last_long_word = next_long_word;
  14.             }
  15.             next_long_word.clear();
  16.         }
  17.     }
  18.     cout << last_long_word;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement