程序代码1:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int exchange(int a, int b)
{
a = a + b;
b = a - b;
a = a - b;
printf("a=%d b=%d", a, b);
}
int main()
{
int a = 0;
int b = 0;
printf("输入a,b的值\n");
scanf("%d %d", &a, &b);
exchange(a, b);
system("pause");
return 0;
}
程序代码2:
#include<stdio.h>
#include<stdlib.h>
void swapArgs(int*i, int*j)
{
int tmp;
tmp = *i;
*i = *j;
*j = tmp;
}
int main()
{
int i = 4, j = 7;
swapArgs(&i, &j);
printf("i=%d,j=%d\n", i, j);
system("pause");
return 0;
}