当前位置:网站首页>两个数相互替换

两个数相互替换

2022-07-05 00:12:00 sunyin.liu

#include <stdio.h>
void swap(int a, int b);
int main(){
	int a = 5;
	int b = 6;
	// printf("a=%d,b=%d\n",a,b);
	printf("a=%d,b=%d\n",a,b);
	swap(a,b);
	
	return 0;
}
void swap(int a,int b){
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;
	printf("a=%d,b=%d\n",a,b);
}

 

原网站

版权声明
本文为[sunyin.liu]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_42066070/article/details/125601216