软件工程导论(第六版)张海藩 牟永敏课后习题答案

法特点,找出并改正伪码中的错误。字频统计程序的伪码如下: INITIALIZE the Program READ the first text record

DO WHILE there are more words in the text record

DO WHILE there are more words in the text record EXTRACT the next text word

SEARCH the word-table for the extracted word IF the extracted word is found INCREMENT the word’s occurrence count ELSE

INSERT the extracted word into the table END IF

INCREMENT the words-processed count END DO at the end of the text record READ the next text record

END DO when all text records have heen read PRINT the table and summary information TERMINATE the program

答:INSERT the extracted word into the table在这个后面,有没有给这个word的occurrence/count赋值为1

第二题

2、研究下面给出的伪码程序,要求: (1) 画出它的程序流程图。

(2) 它是结构化的还是非结构化的?说明理由。 (3) 若是非结构化的,则

(a) 把它改造成仅用3种控制结构的结构化程序; (b) 写出这个结构化设计的伪码; (c) 用盒图表示这个结构化程序。 (4) 找出并改正程序逻辑中的错误。

COMMENT:PROGRAM SEARCHES FOR FIRST N REFERENCES

TO A TOPIC IN AN INFORMATION RETRIEVAL SYSTEM WITH T TOTAL ENTRIES

INPUT N

INPUT KEYWORD(S)FOR TOPIC I=O MATCH=0 DO WHILE I≤T I=I+1

IF WORD=KEYWORD THEN MATCH=MATCH+1 STORE IN BUFFER END

IF MATCH=N THEN GOTO OUTPUT END END IF N=0

THEN PRINT ″NO MATCH″

OUTPUT:ELSE CALL SUBROUTINE TO PRINT BUFFER

INFORMATION END

联系客服:779662525#qq.com(#替换为@)