#include<stdio.h>
void swap(int* p1, int* p2)
{
int t=0;
t = *p1;
*p1 = *p2;
*p2 = t;
}
int main()
{
int a, b, * p1, * p2;
printf("请输入两个数:");
scanf("%d%d", &a, &b);
if (a > b)
swap(&a, &b);
printf("%d %d", a, b);
}
//运用函数参数进行改变值可以减小所用内存
#include<stdio.h>
void swap(int* p1, int* p2)
{
int t=0;
t = *p1;
*p1 = *p2;
*p2 = t;
}
int main()
{
int a, b, * p1, * p2;
printf("请输入两个数:");
scanf("%d%d", &a, &b);
if (a > b)
swap(&a, &b);
printf("%d %d", a, b);
}
//运用函数参数进行改变值可以减小所用内存