[問題] 103中正資管loop invariant

作者: aqeghkmb (瓜)   2017-05-21 00:14:12
which of the following is a loop invariant at the point at which the test for
termination is performed in the following loop structure?
X=3
while(X<5):X=X+2
A.X≦5 B.X<5 C.X≧5 D.X>5
這題答案給D
我上網查了loop invariant 大概是一個敘述在執行前和執行後皆為true 不知道理解有沒
有錯 但這題看不懂為什麼是D 如果皆為true的話我覺得是A
求神人~

Links booklink

Contact Us: admin [ a t ] ucptt.com