从键盘输入3个整数,要求定义3个指针变量p1,p2,p3,使p1指向3个数的最大者,p2 指向次大者,p3指向最小者,然后按由小到大的次序输出3个数。
#include <stdio.h>
void func(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;}printf("由小到大输出:%d,%d,%d\n", *p3, *p2, *p1);
}int main()
{int a=0, b=0, c=0;int* p1=NULL, * p2= NULL, * p3= NULL;p1 = &a, p2 = &b, p3 = &c;scanf("%d,%d,%d", p1, p2, p3);func(p1, p2, p3);return 0;
}