About if (a), if (number) notes

Look at the code

	int i,j;
	for(i = 0 ,j = 5;i=j;){
    
    
		cout<<0<<endl;
		i++;j--;
	}
>0
>0
>0
>0
>0

Output five zeros.
Observe that the condition bit i=j uses the assignment number.
It can also be looped five times
. Under what conditions does if() return true?
Let’s look at one first.

int a;
if(a){
    
    couy<<1;}
if(2){
    
    couy<<1;}
>1
>1

if (a) and if (a!=0) are equivalent,
a is not assigned a value of null, so it returns true
as long as it is not 0, it returns true

Regarding if (a = b), the
Insert picture description hereend is determined by the assignment bit (that is, the number of assignments).
Assume b = 0;
if (a = b) is equivalent to if (a = 0) is equivalent to if (a) is equivalent to if ( a!=0)

Look straight

Guess you like

Origin blog.csdn.net/m0_51641607/article/details/114841136