fork download
  1. #include <cstdio>
  2. #include <string>
  3. #include <algorithm>
  4. #include <iostream>
  5. using namespace std;
  6. int main()
  7. {
  8. string stemp="",sparent="";
  9. string first = "``", second = "''",last="\n";
  10. int count = 1;
  11. while(getline(cin,stemp))
  12. //for (int i=0; i<4; i++)
  13. {
  14. //getline(cin,stemp);
  15. for (size_t i=0; i<stemp.length(); i++)
  16. {
  17. if ((stemp[i]=='"')&&(count == 1))
  18. {sparent.append(first); count=2;}
  19.  
  20. else if((stemp[i]=='"')&&(count == 2)){sparent.append(second); count=1;}
  21.  
  22. else {sparent.append(stemp,i,1);}
  23. }
  24. //sparent.append(last);
  25. cout<<sparent<<"\n";
  26. sparent = "";
  27. }
  28. //cout<<sparent<<"\n";
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 3032KB
stdin
"To be or not to be," quoth the Bard, "that
is the question".
The programming contestant replied: "I must disagree.
To `C' or not to `C', that is The Question!"
stdout
``To be or not to be,'' quoth the Bard, ``that
is the question''.
The programming contestant replied: ``I must disagree.
To `C' or not to `C', that is The Question!''