用指针排序(三个数)
/*************************************
功能:用指针排序(三个数)
日期:2014年12月5日09:49:49
*************************************/
#include<stdio.h>
swap(int *p1, int *p2)
{
int temp;
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
int main()
{
int a, b, c;
int *p1, *p2, *p3;
printf("Input three integers a, b, c\n");
scanf("%d, %d, %d",&a, &b, &c);
p1 = &a;
p2 = &b;
p3 = &c;
if(a > b) swap(p1, p2);
if(a > c) swap(p1, p3);
if(b > c) swap(p2, p3);
printf("Now, the order is :%d, %d, %d \n",a, b, c);
}
/************************************
Input three integers a, b, c
21,98,31
Now, the order is :21, 31, 98
Press any key to continue
**************************************/