寄托天下 寄托天下
查看: 2512|回复: 1

请教一道CS SUB的问题,谢谢! [复制链接]

Rank: 2

声望
0
寄托币
56
注册时间
2006-12-9
精华
0
帖子
2
发表于 2006-12-30 16:47:11 |显示全部楼层
Conside the following program fragment.
  (1) for i=1 to n do
  (2) M = 0
Let A represent the initialzation (i=1) in line (1); let B represent the "body" of the loop; ie., line(2) Let I represent the incrementation of i by 1 implied by line (1), and Let T represent the test for i<=n also impied by line (1).
Which of the following regular expressions represents all possible sequences of steps taken duting execution the fragment, if it is assumed that n is arbitrary and that no abnormal terminations of the loop can occur?
  (A) AT(BIT)* (B) A(ITB)*T    (C)  AT*B*I*T      (D) (ABIT)*  (E) A(TBI)*
答案是A.但不知道是为什么? 能不能帮忙做一下谢谢.:)
回应

使用道具 举报

Rank: 4

声望
0
寄托币
402
注册时间
2006-3-22
精华
0
帖子
7
发表于 2006-12-30 18:37:25 |显示全部楼层
A是循环初始条件(i=1),对于每个循环仅执行一次
T是判断条件i<=n
如果 i 初始值不满足T,则退出循环。这个就是AT
如果满足T,则执行循环体B(M=0)。每执行完一次,i 增加1,即执行I. 然后再来判断i的值是否满足T。这样B-I-T反复下去做,直到i 的值到n+1,不满足判断条件,跳出循环。

使用道具 举报

RE: 请教一道CS SUB的问题,谢谢! [修改]
您需要登录后才可以回帖 登录 | 立即注册

问答
Offer
投票
面经
最新
精华
转发
转发该帖子
请教一道CS SUB的问题,谢谢!
https://bbs.gter.net/thread-586817-1-1.html
复制链接
发送
报offer 祈福 爆照
回顶部