#K69092. Text Autocorrector
Text Autocorrector
Text Autocorrector
You are given multiple lines of text. Your task is to autocorrect certain misspelled words in each line. Specifically, you need to replace all occurrences of teh
with the
and recieve
with receive
, except when these words appear inside double quotes ("
) or after a comment marker //
.
Note that once a //
is encountered and it is not inside quotes, the rest of the line is considered a comment and should remain unchanged. Similarly, any text enclosed within "
remains unchanged.
For example, if a line is:
This is teh editor. // Teh comment
the output should be:
This is the editor. // Teh comment
Implement a program that reads the input from stdin and writes the corrected text to stdout.
inputFormat
The input begins with an integer n representing the number of lines of text. This is followed by n lines where each line is a string.
Input Format:
n line1 line2 ... line n
outputFormat
Output the corrected lines in order. Each line should be printed on a new line.
## sample4
This is teh editor. // Teh comment
"This line will not recieve correction."
recieve teh
"This line has teh" // recieve
This is the editor. // Teh comment
"This line will not recieve correction."
receive the
"This line has teh" // recieve
</p>