函数实现
```
void sort(int* a, int* b, int* c) {
int temp;
if (*a < *b) {
temp = *a;
*a = *b;
*b = temp;
}
if (*a < *c) {
temp = *a;
*a = *c;
*c = temp;
}
if (*b < *c) {
temp = *b;
*b = *c;
*c = temp;
}
}
```
以上代码实现了一个名为`sort`的排序函数,该函数接受三个整型指针作为参数,分别表示需要排序的三个数字。
函数内部通过比较大小,将三个数字按从大到小的顺序排序,并将排序后的结果通过指针返回。
调用方式:
#include <stdio.h>
int main() {
int a, b, c;
printf("请输入三个数字:");
scanf("%d %d %d", &a, &b, &c);
sort(&a, &b, &c);
printf("从大到小的顺序为:%d %d %d\\\\n", a, b, c);
return 0;
}
在`main`函数中,首先通过`scanf`函数获取用户输入的三个数字,并将这三个数字的地址作为参数调用`sort`函数进行排序。
最后,将排序后的结果输出到控制台上。