首页 > 代码库 > 引用作形参--输入三个整数,按从大到小排序

引用作形参--输入三个整数,按从大到小排序

#include <iostream>
using namespace std;
int Fx(int x,int y,int z);
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    Fx(a,b,c);
    return 0;
}
int Fx(int x,int y,int z)
{
    if(x>y&&y>z)
    cout<<x<<"  "<<y<<"  "<<z<<endl;
    else if (x>z&&z>y)
    cout<<x<<"  "<<z<<"  "<<y<<endl;
    else if (y>x&&x>z)
    cout<<y<<"  "<<x<<"  "<<z<<endl;
    else if (y>z&&z>x)
    cout<<y<<"  "<<z<<"  "<<x<<endl;
    else if (z>y&&y>x)
    cout<<z<<"  "<<y<<"  "<<x<<endl;
    else if(z>x&&x>y)
    cout<<z<<"  "<<x<<"  "<<y<<endl;
}
技术分享

引用作形参--输入三个整数,按从大到小排序