DWITE Online Computer Programming Contest, December 2007, Problem 2
There's an issue of plagiarism in every academic course, but it seems to be more common in Computer Science classes, possibly because it's not as apparent to spot as, for example, in an English essay. Though a typical program still contains enough English text in string literals and comments, to be an equivalent of a small essay. The task is to extract just such text from a block of code.
The input will contain five lines of input. Valid ASCII text. String literals will be in either
' quotes. Comments will be C++ style:
/* inline */ and
// end of line. There will be no nested
/* */ comments.
The output will contain five lines, aggregating the text found on the matching lines of the input. The text is defined as any string literal and any comment. Blocks of text found in a line, should be joined together by spaces.
Note: No nested
/* */ comments means there will not be a line of input similar to
/* /* */ */. Comments found inside a string are deemed to be a part of the string. Strings found inside a comment will be deemed to be a part of the comment. One type of a string literal can contain another. See sample input for clarifications.
function my_badly_named_function(); //this is a comment puts "some string content" //and comments go_go("gadget" /* notice extra spaces */); //"for inline comment" "nested 'strings'" /*just some //comments*/
this is a comment some string content and comments gadget notice extra spaces "for inline comment" nested 'strings' just some //comments