输入三个整数将他们从小到大输出

#include<iostream>
using namespace std;
int main()
{
    int x,y,z;
    int t;
    cin>>x>>y>>z;
    if(x>y)
    {
        t=x;
        x=y;
        y=t;
    }
    if(x>z)
    {
        t=x;
        x=z;
        z=t;
    }
    if(y>z)
    {
        t=y;
        y=z;
        z=t;
    }
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_47575628/article/details/109102522
今日推荐