C language summary _02

1. When using a for loop, try to use a half-open and half-closed interval, ->

for(int i = 0;i<10;i++){
    
    
      方法体
}

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

4. When judging whether the variable i is equal to a constant, write the literal constant in front to prevent errors.
E.g:

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

5. The usage of continue in the loop
1) For the more commonly used for loop, using the continue keyword will jump to the position of conditional update.
2) For while and do while, continue will jump to the position of conditional judgment.

Guess you like

Origin blog.csdn.net/CZHLNN/article/details/109130363