求一道题目的算法伪代码A company handles international messages. Currently, the messages are printed ontoa continuous strip of paper which is cut up and pasted onto sheets of paper for delivery.The owner of the company has decided to automa

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/11 02:05:19
求一道题目的算法伪代码A company handles international messages. Currently, the messages are printed ontoa continuous strip of paper which is cut up and pasted onto sheets of paper for delivery.The owner of the company has decided to automa

求一道题目的算法伪代码A company handles international messages. Currently, the messages are printed ontoa continuous strip of paper which is cut up and pasted onto sheets of paper for delivery.The owner of the company has decided to automa
求一道题目的算法伪代码
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个条件,让写伪代码,不要求有全部答案,有个大概思路就好

求一道题目的算法伪代码A company handles international messages. Currently, the messages are printed ontoa continuous strip of paper which is cut up and pasted onto sheets of paper for delivery.The owner of the company has decided to automa
这道题我包了,其他人速速退散.明天告诉你答案.当然只是思路,我从来都是给人渔,而不是鱼.
我睡好了,现在来回答你的问题,感谢楼上的支持!顺便感慨一下老外出的题就是高明,我上学时候没有这么好的题来引导学生.
先看题目,不要太关注于细节,可以用一句话概括这题,那就是把一系列的block转化成message,message由多个page组成.这就是一个程序的高度抽象,以此为准一步一步实现细节.
第二步看你有什么东西可以利用,那就是第8条提到的3个子程序,你要自己写一些程序来调用这3个子程序来实现目标.
先写得到多个block并转成一个message的方法,然后不停调用此方法就行了.
分两步,一是得到构成一个message的多个block,很简单的,伪代码如下:
while(true)
{
getBlock;
if (lastBlock.text == "#")
{
break;//如果刚刚得到的block只包含一个#号,说明是一个message的结束.退出循环,数组中包含的就是构成一个message的所有block
}
}
二是根据这些block,构造message.先把block文本的开头结尾空格除掉,然后把多个连续空格变成一个空格,这些就自己做吧不会再问.
然后顺序根据把block里的每一个单词放到一个临时字符串,每当这个字符串够了100个字,就调用putline,如果不够100,看加上下一个够不够,超了就不要下一个,因为一个单词不能换行.每写够60行就调putPage,直到把所有block都用完.

求一道题目的算法伪代码A company handles international messages. Currently, the messages are printed ontoa continuous strip of paper which is cut up and pasted onto sheets of paper for delivery.The owner of the company has decided to automa 求fleury算法的伪代码 或C语言实现 求本原勾股数组算法的伪代码表示 求两个整数a,b(a>b)的最大公约数的欧几里得算法的 流程图其伪代码如下if(a 写出求1+3+5+7+9+.+99的一个算法的伪代码 写出求a1.a2.a3.a100中最小数的一个算法,要求写伪代码~ apriori算法的伪代码是什么意思?伪代码要出现在程序里面吗? 不能描述算法的是:A.流程图B.伪代码C.数据库D.自然语言 用伪代码表示解不等式ax>b(a不等于0)的算法过程RT. 用递归算法描述Fibonacci数列的伪代码 用递归算法描述Fibonacci数列的伪代码 下列伪代码表示的算法功能是? 求一道简单题目的算法伪代码在n个人中,只有一个人是名人(Celeberty),所有人都认识他而他不认识任何其他n-1个人,其他n-1个人相互是否认识是随机的,现在要一个算法来找出这个名人.要求是 一道C语言的题目求代码 关于算法题两道,用伪代码,1.设计一个求两个正整数数a,b的最小公倍数的算法.这道题帮我看看这样的伪代码行不行r←0 c←0 s←0Read a,bc←bWhile Mod(a,c)≠0r←Mod(a,c)a←cc←rEnd Whiles←a/c×bPrint S2.试 已知a,b属于正整数,a+b=10,设计一个算法,求出ab的最大值,写出伪代码RT 分别用流程图和伪代码的方法描述求找n个整数中最大值的算法? 用伪代码表示求1^3+3^3+5^3+……+1001^3的一个算法