题目:使用函数实现两个数的交换。
C语言代码 编译环境为VS2013
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Exchange(int *a, int *b){
int temp = 0;
temp = *a;
*a = *b;
*b = temp;
}
int main(){
int a = 10;
int b = 20;
Exchange(&a, &b);
printf("交换后的数字为:%d %d\n", a, b);
system("pause");
return 0;
}