fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. string source;
  6. bool isStartMultiComment = 0;
  7. while (getline(cin, source))
  8. {
  9. bool isNotComment = false;
  10. if (source.size() == 0 || source == " ")
  11. {
  12. continue;
  13. }
  14.  
  15. for (int i = 0; i < source.size(); i++)
  16. {
  17. if (source[i] == '/' && source[i + 1] == '/' && !isStartMultiComment)
  18. {
  19. break;
  20. }
  21. else if (source[i] == '/' && source[i + 1] == '*')
  22. {
  23. i++;
  24. isStartMultiComment = true;
  25. }
  26. else if (source[i] == '*' && source[i + 1] == '/' && isStartMultiComment)
  27. {
  28. i++;
  29. isStartMultiComment = false;
  30. }
  31. else if (!isStartMultiComment)
  32. {
  33.  
  34. cout << source[i];
  35. isNotComment = true;
  36. }
  37. }
  38.  
  39. if (isNotComment && !isStartMultiComment)
  40. cout << endl;
  41. }
  42. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty