软件工程复习资料下载:https://download.csdn.net/download/qq_43554335/15492733
软件工程实验三综合设计下载:https://download.csdn.net/download/qq_43554335/15507502
请将下面的非结构化程序改成结构化程序
例1:
非结构化程序:
结构化程序:
flag=true;Do while p and flags1;if q then flag=falseEndDo10:s2例2:
非结构化程序:
结构化程序:
flag=trueDo while p=0 and flagDo while q=0 and flagsa;if r=0 then flag=false;else sb;EndifEndDoEndDoif flag=true:x=20;Endif10: y=40;z=30;例3:
非结构化程序:
结构化程序:
flag:=false; while c1 and (not Flag) do begin Sa; if c2 then flag:=true; else Sb; endif end 10: Sn;例4:
非结构化程序:
结构化程序:
if (N<0) then print “负数”;else if (MOD(N,2)==0) then print “正偶数”;例5:[1]
非结构化程序:
结构化程序:
beginK: = 0; L: = 0; TOTAL: = 0;read( A);while TOTAL〈= 1000 and A〈〉0 dobeginif A〉0 then beginTOTAL: = TOTAL+ A;K: = K+ 1endelse L: = L+ 1;read( A)end;write( K, L, TOTAL)end例6:[1]
非结构化程序:
结构化程序:
bool: = true;while P and bool dobegin…if q then bool: = falseelse begin A; B endend;L1:…例7:[3]
例8:[3]
例9:
非结构化程序:
结构化程序:
if ( A < B and A < C ) then print Aelse if ( A >= B and B < C ) then print Belse print C;参考文献:
[1]hxdxrz,激情的樱桃,长情的香烟.非结构化程序到结构化程序的转化[J].延安大学学报(自然科学版),2000(02):27-32.
[2]当然是施老师上课的PPT啦
[3]美丽的芒果.如何将非结构化程序转化为结构化程序[J].河北工程技术高等专科学校学报,1995(Z2):39-43.
适合于工程大《软件工程》课程期末复习使用,考试占10分。上述答案如有错误请联系博主或评论更正,仅供参考