Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string s, longest, current;
- getline(cin, s);
- int pos;
- pos = 0;
- longest = s.substr(0, s.find(" ", pos));
- while (s.find(" ", pos + 1) != -1) {
- current = "";
- current = s.substr(pos, s.find(" ", pos) - pos);
- if (longest.size() < current.size()) {
- longest = current;
- }
- pos += current.size() + 1;
- cout << current << pos << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement