1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include <stdio.h>
void swap(int *p1, int *p2) { int t; t = *p1; *p1 = *p2; *p2 = t; }
int main() { int a, b, c; int *s1, *s2, *s3; printf("输入3个数:"); scanf("%d %d %d", &a, &b, &c); s1 = &a; s2 = &b; s3 = &c; if (*s1 > *s2) { swap(s1, s2); } if (*s1 > *s3) { swap(s1, s3); } if (*s2 > *s3) { swap(s2, s3); } printf("小到大为: %d %d %d", a, b, c); printf("\n"); }
|