C语言编程>第十九周 ④ 下列给定程序中,函数fun的功能是:实现两个整数的交换。

例题:下列给定程序中,函数fun的功能是:实现两个整数的交换。

例如,给x和y分别输入60和65,输出为:x=65 y=60。
注意:不要改动main函数,不能增行或删行,也不能更改程序的结构。

代码如下:

#include<stdio.h>
#include<conio.h>
void fun(int*x,int*y)
{
    
    
	int t;
	t=*y;*y=*x;*x=t;
}
main()
{
    
    
	int x,y;
	printf("Enter x,y:");
	scanf("%d%d",&x,&y);
	fun(&x,&y);
	printf("x=%d,y=%d\n",x,y);
}

输出运行窗口如下:
在这里插入图片描述

越努力越幸运!
加油,奥力给!!!

猜你喜欢

转载自blog.csdn.net/qq_45385706/article/details/112759911