Advertisement
Guest User

Untitled

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