指针函数参数传递变量地址

编写函数将两个变量的值交换,例如变量a中的值原为3,b中的值原为8,程序运行后a中的值为8,b中的值为3。其中已经给出了部分代码,请你编写要求的函数,将代码补充完整。只提交你写的函数。部分代码如下:
#include

函数写在此处/

int main()
int a b
scanf("%d %d".&a,&b); fun(&a &b);
printf(“%d %d\n",a.b); return 0
【输入】两个整数【输出】
交换后的两个整数【样例输入】35
【样例输出】
53


void fun(int *a,int *b)
{
    int t = *a;
    *a = *b;
    *b = t;
}
 

函数如下

void fun(int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}

使用引用型参数:

#include<stdio.h>
void fun(int &a,int &b)
{
    int temp;
    temp=a;
    a=b;
    b=temp;
}
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    fun(a,b);
    printf("%d %d\n",a,b);
    return 0;
}