用引用交换两个数字

作者在 2009-10-16 09:36:03 发布以下内容
#include<stdio.h>
Swap(int &x,int &y)/*用引用来表示*/
{
 int type;
 
 type=x,x=y,y=type;
 return 0;
}
main ()
{
 int a,b;
 scanf("%d%d",&a,&b);
 printf("the first value:a=%d,b=%d\n",a,b);
 Swap(a,b);
 printf("after swap value:a=%d,b=%d\n",a,b);
 return 0;
}
默认分类 | 阅读 715 次
文章评论,共0条
游客请输入验证码