Description
HIT_TOM gets high score in the course 《Compiling Principle》. So he wants to examine your knowledge of compilation principles.
He will give you some fragment, you need to remove the comments from it.
There are two cases of comments:
- Start with /* and end with */
- Start with //, extending to the end of the line
No characters are allowed to be deleted except for comments.
Input
A code fragment with several lines.
It is guaranteed that the number of characters is not exceeding 1000 for each line.
It is guaranteed that the total number of characters is not exceeding 100000.
Output
For each test case, you need to print all characters of the code except the commexts.
Sample
Hint
It is gurabteed that all characters are English characters. And to simplify the question, we ensure quotation marks ( ’ and " ) will not appear.
It is guaranteed that the test given can be complied by g++.
If you are confused with some situation, you can write you comments on your IDE (maybe codeblocks) to know what you should output.
#include <bits/stdc++.h>
using namespace std;
int main()
{
char op;
queue<char> q;
while(~scanf("%c",&op)){
q.push(op);
}
while(!q.empty()){
if(q.front()=='/'){
q.pop();
if(q.front()=='/'||q.front()=='*'){
while(q.front()!='\n'){
q.pop();
}
}
else printf("/");
}
else{
printf("%c",q.front());
q.pop();
}
}
}