当前位置:网站首页>MOOC Weng Kai C language fourth week: further judgment and circulation: 1. Logical types and operations 2. Judgment of cascading and nesting
MOOC Weng Kai C language fourth week: further judgment and circulation: 1. Logical types and operations 2. Judgment of cascading and nesting
2022-07-28 07:03:00 【W.934】
One . Logical types and operations
1. Logical operations : Logical operation is the operation of logical quantity , It turns out that 0 or 1.
The result of a system operation or logical operation .


Logical operations are performed from left to right .
Don't assign values to , Including compound assignments combined into expressions .
2. Conditional operator
count=(count>20)?count-10:count+10;
? The one in front is Conditions
? The back is Value after conditions are met
: The back is The value after the condition is not satisfied
_ amount to
if(count>20)
count=count-10;
else
count=count+10;( Something left over from the early days of programming languages )
3. The comma operator
Commas are used to connect two expressions , and Take the value of the expression on its right as the result of its operation .
eg: i=(3+4,5+6) The result is 11, namely i=(3+4,5+6)
The priority of commas is the lowest of all operators , So the expressions on both sides of it will be evaluated first ; The combination of commas is from left to right , So the expression on the left will evaluate , The value of the expression on the right is left as the result of the comma operation .
eg:i=3+4,5+6 The result is 7, namely i=3+4,5+6
Comma expression is mainly in for Use of ( At present, there is only one use ): When you want to be in for When placing multiple calculations :
for(i=0,j=10;i<j;i++,j--)
Two . Cascading and nested judgments
1. Nested if-else
else Always the nearest one if matching , Indent format cannot imply if else The matching of .
Suggest : stay if or else Always use... In the back {}, Even when there is only one sentence .
2. Cascade if-else
if(exp1)
st1;
else if(exp2)
st2;
else
st3;
边栏推荐
- Custom components -- slots
- Custom component -- pure data field & component life cycle
- Technology sharing | do you know the functions of the server interface automated testing and requests library?
- MOOC翁恺C语言第八周:指针与字符串:1.指针2.字符类型3.字符串4.字符串计算
- Custom component -- communication between parent and child components
- Hdu-5806-nanoapelovesequence Ⅱ (ruler method)
- Operation document tree
- As a result, fill in the birthday candles
- Results fill in the blank shopping list (teach you to solve it with Excel)
- MOOC翁恺 C语言 第三周:判断与循环:2.循环
猜你喜欢

Centos7 deploy MySQL database server

MOOC翁恺C语言第八周:指针与字符串:1.指针2.字符类型3.字符串4.字符串计算

What kind of air conduction Bluetooth headset with good configuration is recommended

Technology sharing | send requests using postman

2022 Tanabata gift recommendation! Nice, cheap and practical gift recommendation

DOM -- page rendering, style attribute operation, preloading and lazy loading, anti shake and throttling

Iptables firewall

Network - transport layer (detailed version)

NFS 共享存储服务

KVM热迁移
随机推荐
Hdu-5806-nanoapelovesequence Ⅱ (ruler method)
Software testing (concept)
Iptables firewall
Use powercli to create a custom esxi ISO image
Ubuntu18.04搭建redis集群【学习笔记】
Centos7 deploy MySQL database server
What is the good brand of air conduction Bluetooth headset and the best brand recommendation of air conduction headset
Shell script - regular expression
Build php7 private warehouse
Si Han talks about the professional development of testers
Ubuntu18.04+centos7 configure redis master-slave [learning notes]
Traversal binary tree
Life cycle (process) of software testing
Custom components -- slots
Applets: WSX scripts
Hdu-1159-commonsubsequence (LCS longest common subsequence)
Upload and download files from Ubuntu server
Technology sharing | how to do Assertion Verification in interface automated testing?
ES6 add -- > object
QT uses MSVC compiler to output Chinese garbled code