我是
靠谱客的博主
甜甜蜜粉,这篇文章主要介绍
swap的三种写法,现在分享给大家,希望可以做个参考。
复制代码1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void swap1(int &a,int &b)
{
int t=a;
a=b;
b=t;
}
void swap2(int &a,int &b)
{
a=a^b;
b=a^b;
a=a^b;
}
void swap3(int *a,int *b)
{
*a=*a+*b;
*b=*a-*b;
*a=*a-*b;
}
最后
以上就是甜甜蜜粉最近收集整理的关于swap的三种写法的全部内容,更多相关swap内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复