[BOJ 11301] Markleft
View as PDFThere are many markup notations – systems for annotating text with formatting instructions. Markleft is yet another such system. Your task is to implement it.</p>
Markleft takes text input in which punctuation characters are used as follows:
- Text between
^characters should be converted to upper case
eg:One^tWo^threEwill be converted toOneTWOthreE - Text between
\characters should have all double quotes prefixed with\characters
eg:Piglet \said "Hello"\becomesPiglet said \"Hello\" - Text between
#characters will have all embedded numbers (there will never be more than 6 digits in a number) converted to hexadecimal
eg:#Text with 31 12 and 64#becomesText with 1F C and 40 - Text between
<characters should be reversed
eg:This <be reversed<oddbecomesThis desrever ebodd - Text between <code>@</code> characters should be copied verbatim – ie: markup is ignored. Note that this means that there is no way of getting <code>@</code> characters into the output.
eg:This is @\<<#@ verbatimbecomesThis is \<<# verbatim
Markleft sections may be nested, but if so must be nested properly (like matching brackets).
^aa<bcd<ee^ becomes AADCBEE
The following is illegal because the nesting is improper.
One #reverse me ^uppercase me # and more^
Markleft sections are closed by the first validly nested markleft character. There is no nesting in this example
abc^def^ghi^jkl^mno becomes abcDEFghiJKLmno
But nested marklefts of the same kind are possible sometimes. Usually they have little effect, but:
ab<cd^ef<gh<ij^kl<mn becomes ablkJIGHFEdcmn
The markleft application processes innermost nested sections first
<#31#< becomes F1
입력 형식
Input consists of a number of lines of “marked left” text to be formatted. Lines of input are no longer than 100 characters. Each line should be formatted independently. You may assume that lines have valid markup. The end of input is signalled by a line with just a # character.
출력 형식
Lines of formatted text.
예제 입력
One^tWo^threE
Piglet \said "Hello"\
#Text with 31 12 and 64#
This <be reversed<odd
This is @\<<#@ verbatim
^aa<bcd<ee^
abc^def^ghi^jkl^mno
ab<cd^ef<gh<ij^kl<mn
<#31#<
#
예제 출력
OneTWOthreE
Piglet said \"Hello\"
Text with 1F C and 40
This desrever ebodd
This is \<<# verbatim
AADCBEE
abcDEFghiJKLmno
ablkJIGHFEdcmn
F1
Comments