将三个整数从小到大排序
运用指针
#include
void sort3(int *p1, int *p2, int *p3){
if (*p1>*p2){
int temp=*p1;
*p1=*p2;
*p2=temp;
}if (*p1>*p3) {
int temp=*p1;
*p1=*p3;
*p3=temp;
}if (*p2>*p3) {
int temp=*p2;
*p2=*p3;
*p3=temp;
}
}
int main(){
int a,b,c;
scanf("%d %d %d\n",&a,&b,&c);
sort3(&a,&b,&c);
printf("%d %d %d\n",a,b,c);
return 0;
}