编辑代码

#include <stdio.h>

// 指针交换
void Pchange(int *x, int *y){
    int *temp;
    temp = *x;
    *x = *y;
    *y = temp;
}



int main () {
    // 普通交换
    int a = 1, b = 2, temp;
    temp = a;
    a = b;
    b = temp;
    printf("\n普通交换a=%d,b=%d\n",a,b);

    //指针交换
    int c = 1, d = 2;
    int *pc, *pd;
    pc = &c;
    pd = &d;
    Pchange(pc,pd);
    printf("\n指针交换c=%d,d=%d\n",c,d);

}