[求助]关于swap函数
											swap(a,b);
void swap(int x,int y)
{
int temp=x;
x=y;
y=temp;
}
不能交换a,b值
swap(&a,&b);
void swap(int *x,int *y)
{
int temp=*x;
*x=*y;
*y=temp;
}
交换了a,b的值
一直想不通为何的一个不行?有朋友能解释详细点么?
拿这个来一个一个测试就知道了.
#include<stdio.h>
void swap1(int x,int y)
{
    int temp=x;
    x=y;
    y=temp;
}
void swap2(int &x,int &y)
{
    int temp=x;
    x=y;
    y=temp;
}
void swap3(int *x,int *y)
{
    int temp=*x;
    *x=*y;
    *y=temp;
}
void swap4(int *x,int *y)
{
    int *temp=x;
    x=y;
    y=temp;
}
int main()
{
    int a = 3;
    int b = 5;
    printf("a=%d\nb=%d\n",a,b);
    swap4(&a,&b);
    printf("a=%d\nb=%d\n",a,b);
    return 0;
}
