大致结构:
if(condition) {...} else {...}
if(condition) {...}
if(condition) {...} else if {...} else {...}
结构:
switch(variable)
{
case CASE1:
...
break;
case CASE2:
...
break;
default:
...
break;
}
for(;condition;){...}
while(condition) {...}
do{...}while(condition);
循环可以用goto实现
break直接打断循环,continue只打断本次循环
上面所有出现condition的地方,c里定义0
表示false
,其他非零值都是true
,例如:
#include<stdio.h>
int main()
{
if(-1) printf("TRUE\n"); // TURE
return 0;
}
C#里condition,只认识true
和false
,不能直接if(-1)
。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有