编程驴 发表于 2004-8-15 23:07

[求助]小弟初学,遇到问题,请各位大侠指点迷津~万分感谢

<P><b>You are to analyse and design a solution for a simple line editor program which responds to the following commands:</b></P>
<P>
<b>E: Enters edit mode. Allows entry of text. Assume each line is a max of 80 characters and terminate by entering the # symbol.
N: Displays line N. and sets the line index to N.
D: Deletes the current line.
A: Append mode. Text is inserted after the current line. To leave append     mode the user types a #.
P: Print the document on screen.
Q: Quit.</b></P>
<P>
<b>Your proposed solution will have two modes of operation. The default setting is command mode i.e. waiting for one of the above commands. Once a command is entered the program will be in operation mode i.e. inside one of the above commands. Once the command is completed it will be back in command mode. It is strongly recommended you develop the solution in a modular fashion i.e. not simply one huge block of code.</b></P>
<P>大概意思就是编一个简单的行输入程序,按E代表输入数据,每个被输入的数据后要有#作为结束。按N再加行数号可以进入被选行。D意思是删除当前所在的行。A的意思是插入,P为打印,Q是退出。里面还特别指出每次输入最多80个字符。进入程序后按着几个字母就可以表现所要做的command.
小弟为初学者,虽然问题简单,但是还是没有什么思路。望各位老大们帮助~万分感谢
如果觉得麻烦,给个pseudocode介绍一下大体思路也行。3Q!</P>[em02]

flylee 发表于 2004-9-3 12:44

不知道,自己想吧!

lqqnjust 发表于 2008-7-17 11:11

是不是可以用宏定义啊,或者加个switch之类的啊,具体的我也不知道。呵呵

VanHorn 发表于 2008-7-17 19:11

用个while的循环判断里面加个getchar用户输入。根据不同的输入用switch case就搞定了。

页: [1]

编程论坛