当前位置:网站首页>原址 交换
原址 交换
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;

这个方法看起来很好 (少用一个变量),但实际上很少使用,因为它的适用范围很窄:只有定义了加减法的数据类型才能采用此方法。
边栏推荐
- 【Cocos2d-x】截图分享功能
- Layer 2技术方案进展情况
- C语言去除字符串尾部的换行(或其他字符)
- Add and multiply two polynomials using linked list
- Day_ 07 smart communication health project FreeMarker
- Day_ 06 smart health project - mobile terminal development - physical examination appointment
- Day_13 传智健康项目-第13章
- Day_04 传智健康项目-预约管理-套餐管理
- Pyinstaller sklearn报错的问题
- Pat class B 1020 Moon Cake
猜你喜欢

SSM project construction

Basic RF theory (DB)

Docker实战 -- 部署Redis集群与部署微服务项目

Redis 哨兵

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

Layer 2技术方案进展情况

学习太极创客 — ESP8226 (十一)用 WiFiManager 库配网

Infotnews | which Postcard will you receive from the universe?

Radar canvas

Day_ 04 smart health project - appointment management - package management
随机推荐
[cocos2d-x] custom ring menu
Ant Usage Summary (III): batch packaging apk
Remove duplicates from sorted list II of leetcode topic resolution
Matplotlib savefig multiple picture overlay
Pyinstaller sklearn reports errors
WordPress aawp 3.16 cross site scripting
Day_09 传智健康项目-移动端开发-手机快速登录、权限控制
Day_02 传智健康项目-预约管理-检查项管理
Pat class B 1026 program running time
十一、纺织面料下架功能的实现
Day_ 01 smart communication health project - project overview and environmental construction
Global attribute lang attribute
射频内容学习
WordPress contact form entries cross cross site scripting attack
机器学习3-岭回归,Lasso,变量选择技术
Day_08 传智健康项目-移动端开发-体检预约
Progress of layer 2 technical scheme
Visual studio debugging tips
Ansible uses ordinary users to manage the controlled end
mongodb 4.x绑定多个ip启动报错