C下不用中间变量交换两个变量值

 1 #include<stdio.h>
 2 
 3 void inplace_swap(int *int *);
 4 void main(){
 5     int a = 10;
 6     int b = 20;
 7     
 8     inplace_swap(&a, &b);
 9     system("pause");
10 }
11 
12 void inplace_swap(int *x, int *y){
13     *= *^ *y;
14     printf("%d, %d\n"*x, *y);
15     
16     *= *^ *y;
17     printf("%d, %d\n"*x, *y);
18     
19     *= *^ *y;    
20     printf("%d, %d\n"*x, *y);
21 }

posted on 2011-10-11 13:19 灰色客栈 阅读(214) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 
<2011年10月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

导航

统计

常用链接

留言簿

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜