• 三位数排序输出


    #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(或邮件投递)
  • 相关阅读:
    ssh框架整合
    spring事务管理
    spring AOP
    spring静态代理和动态代理
    log4j介绍
    Socket通信介绍
    C# 串口与窗体应用程序的连接
    Halcon中的图像相减算子abs_diff_image和sub_image
    R-CNN、fast-RCNN、faster-RCNN到yolo、SSD简要
    QT入门系列(2):MinGW与MSVC编译的区别
  • 原文地址:https://www.cnblogs.com/TyranRex/p/12146679.html
Copyright © 2020-2023  润新知