当前位置:网站首页>原址 交换
原址 交换
2022-06-23 04:52:00 【Stay--hungry】
不需要辅助空间,进行两个数之间的交换。
int a, b;
cin >> a >> b;
a = a + b;
b = a - b;
a = a - b;
cout << a << ' ' << b;

这个方法看起来很好 (少用一个变量),但实际上很少使用,因为它的适用范围很窄:只有定义了加减法的数据类型才能采用此方法。
边栏推荐
- Day_08 传智健康项目-移动端开发-体检预约
- WordPress aawp 3.16 cross site scripting
- Tcp/ip explanation (version 2) notes / 3 link layer / 3.4 bridge and switch
- mongodb 4. X binding multiple IP startup errors
- Progress of layer 2 technical scheme
- 【Leetcode】431. Encode N-ary Tree to Binary Tree(困难)
- Pat class B 1021 digit statistics
- Network packet capturing tcpdump User Guide
- Find the number of nodes in the widest layer of a binary tree
- Pyqt5 设置窗口左上角图标
猜你喜欢

Day_02 传智健康项目-预约管理-检查项管理

Day_ 06 smart health project - mobile terminal development - physical examination appointment
![[open source project] excel export Lua configuration table tool](/img/3a/8e831c4216494d5497928bae21523b.png)
[open source project] excel export Lua configuration table tool

Difference between MySQL read committed and repeatability

How to query fields separated by commas in MySQL as query criteria - find_ in_ Set() function

Day_04 傳智健康項目-預約管理-套餐管理

Detailed explanation of redis persistence, master-slave and sentry architecture

11、 Realization of textile fabric off shelf function

Day_04 传智健康项目-预约管理-套餐管理

Machine learning 3-ridge regression, Lasso, variable selection technique
随机推荐
How to batch produce QR codes that can be read online after scanning
WordPress contact form entries cross cross site scripting attack
Pat class B 1017 C language
Pat class B 1021 digit statistics
Memory analysis and memory leak detection
同步开关电源降低EMI布局 dv/dt di/dt
Leetcode topic resolution remove nth node from end of list
密码学系列之:PKI的证书格式表示X.509
【Leetcode】431. Encode n-ary tree to binary tree (difficult)
Remove duplicates from sorted list II of leetcode topic resolution
【DaVinci Developer专题】-41-APP SWC如何读取写入NVM Block数据
【已解决】“The Unity environment took too long to respond. Make sure that :\n“
Pat class B 1016 C language
WordPress aawp 3.16 cross site scripting
Day_ 04 smart health project - appointment management - package management
Runc symbolic link mount and container escape vulnerability alert (cve-2021-30465)
Pat class B 1026 program running time
Leetcode topic resolution valid Sudoku
C语言 获取秒、毫秒、微妙、纳秒时间戳
Day_ 02 smart communication health project - appointment management - inspection item management