三位数排序输出

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
// 三数排序--从大到小
void sort(float x, float y, float z)
{
if (x > y)
{
if (x > z)
{
printf("最大数是:%f ", x);
if (z > y) {
printf("第二大数是:%f ", z);
printf("最小数是:%f ", y);
}
else {
printf("第二大数是:%f ", y);
printf("最小数是:%f ", z);
}
}
else if (x < z) {
printf("最大数是:%f ", z);
printf("第二大数是:%f ", x);
printf("最小数是:%f ", y);
}
}
else if (y > z)
{
if (y > x)
{
printf("最大数是:%f ",y);
if (x > z) {
printf("第二大的数是:%f ", x);
printf("最小数是:%f ", z);
}
else {
printf("第二大的数是:%f ", z);
printf("最小数是:%f ", x);
}
}
else if (y < x) {
printf("最大数是:%f ", x);
printf("第二大数是:%f ", y);
printf("最小数是:%f ", z);
}
}
else if (z > x)
{
if (z > y)
{
printf("最大数是:%f ", z);
if (y > x) {
printf("第二大数是:%f ", y);
printf("最小数是:%f ", x);
}
else {
printf("第二大数是:%f ", x);
printf("最小数是:%f ", y);
}
}
else if (z < x) {
printf("最大数是:%f ", x);
printf("第二大数是:%f ", z);
printf("最小数是:%f ", y);
}
}
}

int main()
{
float x, y, z;
cin >> x >> y >> z;
sort(x, y, z);
return 1;
}

在本博客上的内容全部共享公开不收费 转载请注明出处,尊重知识,尊重劳动 对代码或者知识有疑问,可联系博主(qq):2218787597(或邮件投递)
原文地址:https://www.cnblogs.com/TyranRex/p/12146679.html