关于Pascal中选择结构的问题

来源:百度知道 编辑:UC知道 时间:2024/09/28 13:34:37
有个关于Pascal的选择结构的问题。
为什么
if(a<b)and(b<c) then 语句1
else 语句2;
这段程序与
if a<b then
if b<c then语句1
else语句2
不等效,而是与
if a<b then begin
if b<c then 语句1
else 语句2;
end
else 语句3;
这个是等效的?

请注意,else是和离它最近的if配套的。所以
if a<b then
if b<c then语句1
else语句2
意味着,当a<b且b>=c时,执行语句2,和
if(a<b)and(b<c) then 语句1
else 语句2;
就不是一个意思了。