母乳常温下能放多久:怎么把 if 语句转case 语句

来源:百度文库 编辑:中科新闻网 时间:2024/05/07 17:10:49
如题

如果多个if语句的条件有是有序类型,就能够转换

如if a=1 then...
if a=2 then...
可以写成
case a of
1:....
2:....
end;

以上是delphi代码
C++用switch语句,VB用select语句

dim a as integer
select case a
case 1
....
case 2
....
end select

比如
if(x==1)
printf("x=1");
else printf("x!=1");

switch(x)
{
case 1 : printf("x=1"); break;
default : printf("x!=1");
}