当前位置:网站首页>Swap numbers (no temporary variables)
Swap numbers (no temporary variables)
2022-06-11 05:21:00 【Food can be very delicious】
That's interesting , Although the meaning of science and technology is not big , But tuyile
Title Description
Write a function , No temporary variables , Direct exchange numbers = [a, b] in a And b Value .
Ideas
Method 1
Add
a=x
b=y
a=a+b=x+y
b=a-b=x+y-y=x
a=a-b=x+y-x=y
Method 2
Bad
a=x
b=y
a=a-b=x-y
b=a+b=x-y+y=x
a=b-a=x-x+y=y
Method 3
Exclusive or
a!=b
a^=b
b^=a
a^=b
A little enlightening , After all
Two identical numbers are XOR equal to 0,0 And any number exclusive or is equal to the number itself
This theorem is very useful
边栏推荐
- Poverty has nothing to do with suffering
- 6 questions to ask when selecting a digital asset custodian
- Huawei equipment is configured with bgp/mpls IP virtual private network
- In the future, how long will robots or AI have human creativity?
- Oh my Zsh correct installation posture
- mysql字符串转数组,合并结果集,转成数组
- Conversion relationship between coordinate systems (ECEF, LLA, ENU)
- MySQL regularly deletes expired data.
- 微信小程序,购买商品属性自动换行,固定div个数,超出部分自动换行
- Huawei device configuration bgp/mpls IP virtual private network command
猜你喜欢

Preliminary test of running vins-fusion with zed2 binocular camera

Oh my Zsh correct installation posture

在未来,机器人或 AI 还有多久才能具备人类的创造力?

NVIDIA SMI has failed because it could't communicate with the NVIDIA driver

(十五)红外通信

点击图标不灵敏咋整?

高斯白噪声(white Gaussian noise,WGN)

Emnlp2021 𞓜 a small number of data relation extraction papers of deepblueai team were hired

Deep search + backtracking

Cross modal retrieval | visual representation learning
随机推荐
Deep extension technology: intelligent OCR recognition technology based on deep learning has great potential
49. grouping of acronyms
NVIDIA SMI has failed because it could't communicate with the NVIDIA driver
在未来,机器人或 AI 还有多久才能具备人类的创造力?
Inventory | ICLR 2022 migration learning, visual transformer article summary
Preliminary understanding of DFS and BFS
Preliminary test of running vins-fusion with zed2 binocular camera
Combien de courant le câblage des PCB peut - il supporter?
Share | guide language image pre training to achieve unified visual language understanding and generation
What is the difference between gigabit network card and 10 Gigabit network card?
About custom comparison methods of classes and custom methods of sort functions
Oh my Zsh correct installation posture
js promise,async,await简单笔记
New product pre-sale: 25g optical network card based on Intel 800 series is coming
截取文件扩展名
Exhibit express: Lianrui will bring three new products of the industry to debut in visionchina (Shenzhen) 2021
Take stock of the AI black technologies in the Beijing Winter Olympic Games, and Shenzhen Yancheng Technology
go单元测试实例;文件读写;序列化
The data center is evolving towards the "four high" trend, and the OCP network card and the whole cabinet will be delivered into the mainstream of the future data center
(十五)红外通信