使用函数实现两个数的交换
#include<stdio.h>
#include<stdlib.h>
void exchange(int* a,int* b) {
int temp;
temp = *a;
*a = *b;
*b = temp;
}
int main() {
int a = 10;
int b = 20;
exchange(&a, &b);
printf("a=%d,b=%d", a, b);
system("pause");
return 0;
}
使用函数实现两个数的交换
#include<stdio.h>
#include<stdlib.h>
void exchange(int* a,int* b) {
int temp;
temp = *a;
*a = *b;
*b = temp;
}
int main() {
int a = 10;
int b = 20;
exchange(&a, &b);
printf("a=%d,b=%d", a, b);
system("pause");
return 0;
}