fork(4) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string a;
  8. getline(cin,a);
  9. string b;
  10. b+=a[0];
  11. for (int i=1; i<a.length(); i++)
  12. {
  13. if ((a[i]!=' ')|| ((a[i]==' ') and (a[i-1]!=' '))) b+=a[i];
  14. }
  15. cout<<b;
  16.  
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 2820KB
stdin
         drg      sdg        gh
stdout
 drg sdg gh