博客
关于我
c语言小总结_02
阅读量:82 次
发布时间:2019-02-26

本文共 424 字,大约阅读时间需要 1 分钟。

1、在用for循环的时候,尽量用半开半闭区间,->

for(int i = 0;i<10;i++){         方法体}
当用数组去写算法的时候,就会有所体会。2、逗号表达式:依次向右执行,而且是从左向右依次全部被执行,最后的结果以最后的表达式为准。3、在c语言中,出现出样的条件判断:```cint i = 0;```if(i = 5){    xxxx}等价于:if(i);在C语言中0表示假,非0表示真。这种情况,()中的条件总是是成立的,while(i = 5){}这种情况就会出现死循环。

4、当判断变量 i 是否等于一个常数的时候,要把字面常量写在前面防止出错。

例如:

if(1==k){   }   while(1==k){   }

5、continue在循环中的用法

1)对于比较常用的for循环,使用continue关键字会跳到条件更新的位置。
2)对于while和do while,continue会跳到条件判定的位置。

转载地址:http://dwcz.baihongyu.com/

你可能感兴趣的文章
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>