fork(2) download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. bool BothAreSpaces(char lhs, char rhs) { return (lhs == rhs) && (lhs == ' '); }
  6.  
  7. int main() {
  8. string str;
  9.  
  10. getline(cin, str);
  11.  
  12. str.erase(unique(str.begin(), str.end(), BothAreSpaces), str.end());
  13.  
  14. cout << str;
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0.01s 2860KB
stdin
a b  c   def g  hj  k
stdout
a b c def g hj k