fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9. cin >> noskipws;
  10. char c = 0, f = 0;
  11. for(bool first = true; cin >> c; )
  12. {
  13. if (c == ' ')
  14. {
  15. first = true;
  16. cout << c;
  17. }
  18. else
  19. if (first)
  20. {
  21. first = false;
  22. cout << (f = c);
  23. }
  24. else
  25. {
  26. if (c != f) cout << c;
  27. }
  28. }
  29. }
  30.  
Success #stdin #stdout 0s 5692KB
stdin
aagfaahjh jhsqdkjjweg  hdsjhshsahhh   jhssah    jsha
stdout
agfhjh jhsqdkweg  hdsjssa   jhssah    jsha