编程介的小学生 2018-11-10 17:36 采纳率: 20.5%
浏览 367
已采纳

一个文本编辑器标识语言方面的问题,具体看里面的详细说明

Problem Description
Mark-up languages are computer languages that assist in the formatting of text files. Special keywords are used to mark the text to allow control of fonts, page styles, paragraph styles, etc. TeX, troff, and HTML are examples of mark-up languages.

Spell checking can be difficult to adapt to these special texts. In general, special processors or spell checkers must be created in order to accommodate mark-up languages. A special processor would recognize the mark-up language and strip it from the text so that the ``plain'' text could then be processed by a spell checker. For this problem, you are to write such a processor for a small mark-up language so that the output of your program will be the plain text without the mark-ups.

The mark-up language to consider is one which allows the modification of fonts within the text. Each markup command will be preceded by a \ character. If the letter following the \ character is not a recognized command from the table below then the character following the \ is printed as part of the plain text. For instance, the mark-up \ can be used to print a single .

\b
toggle bold font on/off (default state is off)
\i
toggle italics font on/off (default state is off)
\s
set font size; the s is immediately followed by an optional number; if the number is missing then the command will restore the previous size
*
toggle processing of mark-ups on/off; if processing is toggle off then mark-ups are considered to be literal text (default state is on)

The number following the \s command can have a decimal point so 12, 9.5, 11., and .5 should all be recognized as valid numbers.

Input
The input file will be plain text containing mark-ups from the language above. At the start, processing of mark-ups should be on. The file should be processed until the end-of-file is encountered.

Sample Input
\s18.\bMARKUP sample\b\s

*For bold statements use the \b command.*

If you wish to \iemphasize\i something use the \i command.

For titles use \s14BIG\s font sizes, 14 points usually works well.

Remember that all of the commands toggle except for the \s command.

Sample Output
MARKUP sample

For bold statements use the \b command.

If you wish to emphasize something use the \i command.

For titles use BIG font sizes, 14 points usually works well.

Remember that all of the commands toggle except for the \s command.

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-12-04 13:17
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 vc6.0中想运行代码的时候总是提示无法打开文件是怎么回事
  • ¥25 关于##爬虫##的问题,如何解决?:
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题