Hide

Problem H
Kommentarer

Författaren Filip brukar skriva kommentarer till sig själv när han skriver böcker. För att kunna skilja kommentarerna från den vanliga texten så inleder och avslutar han kommentarerna med speciella tecken. I början av sin karriär så inledde han och avslutade kommentarer med ”%”. Då kunde hans text se ut så här:

”Charles knocked on the door and a woman opened it. % Don’t forget that Charles has already met this woman in chapter 5! % She looked at him.

- Yes?, she said.”

Senare kom Filip på att det nog vore bra att i stället inleda kommentarer med /* och avsluta dem med */. Då skulle texten i stället se ut så här:

”Charles knocked on the door and a woman opened it. /* Don’t forget that Charles has already met this woman in chapter 5! */ She looked at him.

- Yes?, she said.”

Nu använder Filip bägge systemen om vartannat, så att samma text kan innehålla både kommentarer mellan två %-tecken, och kommentarer mellan /* och */. Detta driver hans förläggare till vansinne. Din uppgift är nu att skriva ett program som tar bort alla kommentarer ur Filips manuskript, och bara behåller boktexten.

\includegraphics[width=8cm]{typewriter.jpg}

Indata

Indata består av en text med kommentarer. Du kan förutsätta att texten är mellan 2 och 10000 tecken lång, och att den enbart innehåller tecknen a-z, A-Z, 0-9, samt några vanliga skiljetecken (.,!?%/*’-).

Utdata

Utdata ska bestå av den filtrerade texten utan kommentarer. Ifall en kommentar öppnas, antingen med % eller /*, men aldrig avslutas, så antas kommentaren fortsätta ända tills slutet av texten.

Sample Input 1 Sample Output 1
Charles knocked on the door and a woman 
opened it. % Don't forget that Charles 
has already met this woman in chapter 5! % 
She looked at him.
- Yes?, she said.
Charles knocked on the door and a woman 
opened it.  
She looked at him.
- Yes?, she said.
Sample Input 2 Sample Output 2
Charles knocked on the door and a woman 
opened it. /* Don't forget that Charles 
has already met this woman in chapter 5! */ 
She looked at him.
- Yes?, she said.
Charles knocked on the door and a woman 
opened it.  
She looked at him.
- Yes?, she said.
Sample Input 3 Sample Output 3
Charles knocked on the door and a woman 
opened it. /* I'm not 100% sure this is 
a good development of the plot. */ 
She looked at him.
- Yes?, she said.
Charles knocked on the door and a woman 
opened it.  
She looked at him.
- Yes?, she said.
Sample Input 4 Sample Output 4
Charles knocked on the door and a woman 
opened it. % Hmm, is this good... /* Not 
sure */ Perhaps this should happen in 
chapter 10 instead? % She looked at him.
- Yes?, she said.
Charles knocked on the door and a woman 
opened it.  She looked at him.
- Yes?, she said.
Sample Input 5 Sample Output 5
Charles knocked on the door and a woman 
opened it. % Hmm, is this good... /* Not 
sure to 100% */ Perhaps this should happen 
in chapter 10 instead? % She looked at him.
- Yes?, she said.
Charles knocked on the door and a woman 
opened it.  */ Perhaps this should happen 
in chapter 10 instead? 

Please log in to submit a solution to this problem

Log in