Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int main() {
- std::string s, f = "";
- getline(std::cin, s);
- for(int i = 0; i < s.size(); i++) {
- if (s[i] != ' ')
- f += s[i];
- else
- if (f[f.size() - 1] != ' ')
- f += ' ';
- }
- std::cout << f;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement