给定两个整形变量的值,将两个值的内容进行交换。
#include <stdio.h>
void Swap1(int x, int y)
{
int temp = x;
x = y;
y = temp;
system(“pause”);
}
void Swap2(int *px, int *py)
{
int temp = *px;
*px = *py;
*py = temp;
system(“pause”);
}
int main()
{
int a = 15;
int b = 20;
Swap1(a, b);
printf(“Swap1: a= %d b= %d\n”, a, b);
Swap2(&a, &b);
printf(“Swap2: a= %d b= %d\n”, a, b);
return 0;
system(“pause”);
}