Before subject,I recommend a book -- C++ guide for coding to help you adjusting the coding

of specification. Then in programme,0 usually define false and not 0 usually

define true.Many time ,we usually use 1 to showcase true.

1.relational manipulate symbol.(> < >= <= == !=)

For example,a==b.If it establish,it will return 1 or return 0.

(A notice ,we usually put constant into left such as 3 == a to help check such as

3 = a 's error )

2.logic manipulate symbol

(1)     exp1?exp2;exp3 

When exp1 is true ,return the value of expresion by exp2 or return he value of

expresion by exp3.

(2) && and || 

For example ,a&&b ,when a,b are true will return 1 or return 0.

a||b,when a or b or both have one true will return 1 or return 0.

In this have a principle ,Short Circuit.

whatever && or ||,they all follow calculate from left to right. If && have a false

,it will stop calculate later expression while || have a ture which will stop calculate later expression

too.

For example,  a=0,b=2,d=3(a++ &&++b&&d++)

For a++ &&++b,a++will return 0,which will bring && return 0,so a++ &&++b&&d++

will turn to 0 &&d++.Because 0 make && not working,d++ will not working too!

Then a will become 1,b=2,d=3.

Example 2,a=0,b=2,d=3(a++ ||++b||d++)

For a++ ||++b,a++ will return 0,which make || continue,then ++b will return 3,which

will make || return 1,so the expression will become 1||d++.Because 1 ,|| will stop,which

make d++ pause and return 1.At last a = 1,b = 3,d = 3.

(3)         ,   (This is a expression)

For example ,int a = (a = 3,a+3,b=a+3,c=(2*a)+b).

In the bracket,It will operating from left to right and the return value is the last outcome

of expression.(!!!    =  assignment control symbol will not return value)

3.switch sentence.

From nature,switch is the simplied" if sentence ".

For example,switch(a)                                if(a == 1)

case 1:                                                         else if(a == 2)                                           

                                                                     else if(a == 3)

case 2:

case like the == to distinguish different number or case.But switch should use break to seperate different manner.And switch use deflaut to handle other case.

4.for and while circle words.

Those both have  start circle variable,judge ending condition and adjust circle variable

while(judge ending condition)

{

start circle variable;

adjust circle variable;

}

for(start circle variable;judge ending condition;adjust circle variable)

{

}

Logo

码道开发者社区,聚焦华为云码道 CodeArts 代码智能体,沉淀 Agent、Skill、鸿蒙开发实战内容,供开发者查阅资料、交流技术、分享工程实践

更多推荐