#include<stdio.h>
int a_1(int x,int y); //函数声明
int a,b,t; //全局变量
main()
{
scanf("%d %d",&a,&b);
a_1(a,b);
}
int a_1(int x,int y)
{
t=x; //x,y的值交换
x=y;
y=t;
printf("%d %d",x,y);
}
以下是书上的例题为例:
#include<stdio.h>
int swap(int *x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
main()
{
int a,b;
scanf("%d %d",&a,&b);
swap(&a,&b);
printf("%d %d",a,b);
}
以上两个程序的结果一致;