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

引用作形参--输入三个整数,采用地址的方法按从大到小排序

#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;
}
技术分享

引用作形参--输入三个整数,采用地址的方法按从大到小排序