当前位置:网站首页>The difference between the increment and decrement operators before and after variables i+, +i, I –, – I
The difference between the increment and decrement operators before and after variables i+, +i, I –, – I
2022-06-13 05:54:00 【Python's path to becoming a God】
Auto increment and auto decrement operator yes Composite operators A simpler way of writing
Variable a Add yourself 1 Can be expressed as :
a=a+1;
Composite operators notation
a+=1;
Self - increment operator notation
a++;
++a;
Correspondingly, there are Self - subtracting operator notation
a--;
--a
After the completion of self increase and self decrease , Meeting Replace old value with new value Save in current Variable in .
The result of self increasing and self decreasing must have a variable to receive , Therefore, self increase and self decrease can only be applied to Variable , Cannot be for numbers or expressions .
Pre auto increment ( Self reduction ) Self increasing after and ( Self reduction ) The difference between :
An example : Output i The value after self increment and are respectively i++ and ++i The assignment of j Value , Analyze the difference between the two kinds of autoincrement
#include <stdio.h>
int main() {
int i = 5, j;
j = i++;
printf("i=%d,j=%d\n", i, j);
i = 5;
j = ++i;
printf("i=%d,j=%d\n", i, j);
return 0;
}

According to the observation results i All values change to 6, however j But they are assigned to 5 and 6, That is to say, the difference between pre auto increment and post auto increment is that the value is assigned after auto increment , The other one assigns values first and then increases automatically .
Mnemonics :
【 According to the assignment character ‘=’ After Variable i In the form of Judge i Whether the value before or after auto increment is assigned to j】
if 【++i】, Then put ++i As a whole , Put the self increasing i value (++i) Assign to j( Self increment and then assignment );
if 【i】, First put i Value is assigned to j, let i Self increasing ( First assign value and then auto increment ).
( Self subtraction as above )
边栏推荐
- Shardingsphere JDBC < bind table > avoid join Cartesian product
- Working principle of sentinel series (concept)
- What happens when the MySQL union index ABC encounters a "comparison operator"?
- Leetcode- intersection of two arrays ii- simple
- Leetcode- intersection of two arrays - simple
- 13 cancelendevent of a flowable end event and compensationthrowing of a compensation event
- Leetcode- reverse string ii- simple
- Top slide immersive dialog
- The SQL file of mysql8.0 was imported into version 5.5. There was a pit
- Ffmpeg download suffix is Video files for m3u8
猜你喜欢

SPI primary key generation strategy for shardingsphere JDBC

2021.9.30学习日志-postman

Byte buddy print execution time and method link tracking

Misunderstanding of tongweb due to ease of use

Four shardingsphere JDBC sharding strategies

Experience of redis installation under Linux system (an error is reported at the same time. The struct redis server does not have a member named XXXX)

3. Postman easy to use

Ffmpeg download suffix is Video files for m3u8

ffmpeg 下载后缀为.m3u8的视频文件

Vagrant virtual machine installation, disk expansion and LAN access tutorial
随机推荐
Current limiting and fusing of gateway gateway in Spirng cloud
No assessment summary
Leetcode- first unique character in string - simple
12 error end event and terminateendevent of end event
Calculate the number of days between two times (supports cross month and cross year)
High availability of Nacos series
Mobile end adaptation scheme
2 first experience of drools
Sentinel series integrates Nacos and realizes dynamic flow control
arrayList && linkedList
The reason why the process cannot be shut down after a spark job is executed and the solution
Conf/tongweb Functions of properties
Leetcode- find all missing numbers in the array - simple
Integer tips
顶部下滑沉浸式dialog
Feel the power of shardingsphere JDBC through the demo
powershell优化之一:提示符美化
Application virtual directory static resource configuration on tongweb
2021.9.29 learning log restful architecture
Mongodb multi field aggregation group by