#include "stdio.h"
void sort(int *, int *, int *);
void main()
{
int a, b , c, *pointer_1, *pointer_2, *pointer_3;
pointer_1 = &a;
pointer_2 = &b;
pointer_3 = &c;
printf ("input 3 numbers:");
scanf ("%d,%d,%d", &a, &b, &c);
sort(pointer_1, pointer_2, pointer_3);
printf ("%d,%d,%d\n", *pointer_1, *pointer_2, *pointer_3);
}
void sort(int *p1, int *p2, int *p3)
{
int t;
if ( *p1 > *p2){ t = *p1; *p1 = *p2; *p2 = t;}
if ( *p1 > *p3){ t = *p1; *p1 = *p3; *p3 = t;}
if ( *p2 > *p3){ t = *p2; *p2 = *p3; *p3 = t;}
}
输入三个数字,使用指针,是三个数字按从小到达输出
最新推荐文章于 2022-05-13 18:07:46 发布