#include
void main()
{
void swap(int *m , int *n);
int a, b;
printf("Please input two integers a and b:");
scanf("%d%d",&a, &b);
swap(&a,&b);
printf("Now a and b have been converted\n");
printf("a=%d , b=%d\n", a, b);
}
void swap(int *m,int *n)
{
int temp;
temp = *m;
*m = *n;
*n = temp;
}
运行通过!
void swap(int *a, int *b)
{
int t = *a;
*a=*b;
*b =*a;
}
由于未给出变量值的类型,所以应用模板
template
void swap(T *a,T *b )
{
T c;
c=a;
a=b;
b=c;
}