代码
代码语言:javascript
复制//
// Created by 冲哥 on 2021/01/12.
//
#include <stdio.h>
//微信关注C语言中文社区,免费领取200G学习资料
int main() {
int A, B, C;//用A、B、C分别接收输入的三个数
int *p1, *p2, *p3, temp;
printf("请输入三个整数:n");
scanf("%d%d%d", &A, &B, &C);
printf("输入的三个数是:%d,%d,%dn", A, B, C);
p1 = &A;
p2 = &B;
p3 = &C;
if (*p1 < *p2) {
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
if (*p2 < *p3) {
temp = *p2;
*p2 = *p3;
*p3 = temp;
}
if (*p1 < *p2) {
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
printf("将输入的三个数按从大到小的顺序输出:%d,%d,%dn", A, B, C);
return 0;
}
运行结果