#include<stdio.h>
void swap1(int*,int*);
void swap2(int*,int*);
int main()
{
int i,j;
scanf("%d,%d",&i,&j);
printf("1: i=%d,j=%d\n",i,j);
swap1(&i,&j);
printf("2: i=%d,j=%d\n",i,j);
swap2(&i,&j);
printf("3: i=%d,j=%d\n",i,j);
return 0;
}
void swap1(int* a,int* b)
{
*a = *a ^ *b;
*b = *b ^ *a;
*a = *a ^ *b;
}
void swap2(int* a,int* b)
{
*a = *a + *b;
*b = *a - *b;
*a = *a - *b;
}
./swap 10,20 1: i=10,j=20 2: i=20,j=10 3: i=10,j=20
|