65,211
社区成员
发帖
与我相关
我的任务
分享下面的1和2有什么区别:
1:
void swap(int &a, int &b)
{
int temp;
temp=a;
a=b;
b=temp;
}
main()
{
int a=1,b=3;
swap(a,b);
return 0;
}
2:
void swap(int *p1, int *p2)
{
int *temp;
*temp=*p1;
*p1=*p2;
*p2=temp;
}
main()
{
int a=1,b=3;
swap(&a,&b);
return 0;
}