求一道题目的算法伪代码
A company handles international messages. Currently, the messages are printed onto
a continuous strip of paper which is cut up and pasted onto sheets of paper for delivery.
The owner of the company has decided to automate this process, printing the messages
directly onto sheets of paper. Your task is to develop a pseudo code algorithm to achieve
this purpose. The owner can tell you the following things:
1. The incoming message arrives in the form of a series of one or more blocks of data.
2. The outgoing message will be produces as a series of pages.
3. Each page may contain up to 60 lines.
4. Each line can contain up to 100 characters.
5. Words may not be split across lines.
6. As many words as possible must be fitted onto each line.
7. Each message must start on a new page.
8. You have 3 sub-programs already provided.
a. getBlock which fills an array with the next incoming block of text.
b. putLine which prints the next line of text onto the page.
c. putPage which ejects the current page and starts the next.
9. Each block can hold up to 500 characters.
10. The end of a block is designated by the character ‘#’.
11. The 500 character limit includes the end of block character.
12. The end of a message is designated by an empty block.
13. An empty block consists of a one-character long block containing ‘#’.
14. The character ‘#’ only appears as the end of a block.
15. A message consists of a series of words.
16. Words are separated by spaces, sequences of one or more occurrences of the ‘ ’
character.
17. The alphabet consists of the capital letters ‘A’ to ‘Z’ , the space ‘ ’ and the hash ‘#’.
18. Numbers and punctuation are spelled out
19. On arrival, the first word of a message may have spaces before it.
20. On arrival, the last word of a message may be followed by spaces.
21. On Arrival, there may be multiple spaces between words.
22. Blocks may consist entirely of spaces.
23. On arrival, words may be split between blocks.
24. On output there must be no space before the first word on any line
25. On output there will be no more than 1 space between words
26.No word in the message will be longer than 100 characters.
You should create a solution in which the Algorithm is clear and easily tested.
Use the principles of top-down design and modular programming.
Select one of the sub-algorithms you create and provide a detailed flow chart for it following
the rules and conventions taught in class.
给出了26个条件,让写伪代码,不要求有全部答案,有个大概思路就好
人气:167 ℃ 时间:2020-05-17 09:28:54
解答
这道题我包了,其他人速速退散.明天告诉你答案.当然只是思路,我从来都是给人渔,而不是鱼.我睡好了,现在来回答你的问题,感谢楼上的支持!顺便感慨一下老外出的题就是高明,我上学时候没有这么好的题来引导学生.先看题目,...
推荐
猜你喜欢
- 在核电荷数1----18的元素内,列举两个与氧核外电子层排布相同的离子符号
- 有甲乙两种卡车,甲车每次可装煤6吨,乙车每次可装煤8吨,现有煤146吨,要求一次运完,而且每一辆车都装满,需要甲乙两种卡车各多少辆?
- When is the Mother's Day?好,还是When is Mother's day?好.哪个句子比较恰当,个人觉得不要the 好一点
- -4,8,-16,32,-64.将这一行数前5个数用乘方表示.
- 1,2,3,4 0.8,4,2.8,2 2.7,9,0.9,3
- NH4NO3在水中的电离方程式
- 如何确定二次函数的表达式,即解法
- 为什么说点燃蜡烛时既有物理变化,又有化学变化?