fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long a=1;
  4. int main()
  5. {
  6. string s;
  7. getline(cin,s);
  8. for(int i=0;i<s.size();i++)
  9. {
  10. if(s[i]==' ')
  11. {
  12. while(s[i+a]==' ')
  13. {
  14. s.erase(s.begin() + i+a);
  15. }
  16. }
  17. a=1;
  18. }
  19. cout<<s<<endl;
  20. }
  21.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout