分类: C/C++
2009-09-13 19:40:13
#include <stdio.h>void intSwap(int *pTest1, int *pTest2);int main(int argc, char *argv[]){ int a,b; puts("Input first integer:"); scanf("%d", &a); puts("Input second integer:"); scanf("%d", &b); intSwap(&a, &b); printf("Output,swap two integers:\t%d\t%d\n",a , b); exit(0);}void intSwap(int *pTest1,int *pTest2){ *pTest1 ^= *pTest2; *pTest2 ^= *pTest1; *pTest1 ^= *pTest2;}
运行输出(红色为自己输入的数值):
Input first integer:
10
Input second integer:
5
Output,swap two integer: 5 10