#include<iostream>
using namespace std;
void swap(int &x,int &y){ int z=x; x=y; y=z; }
int main(){
int a,b,c,d,e;
while(cin>>a>>b>>c>>d>>e){
if(a>b) swap(a,b);
if(c>d) swap(c,d);
if(b>d){ b=d; swap(a,c); }
if(c>e) swap(c,e);
if(b>e){
if(a>e) cout<<a<<endl;
else cout<<e<<endl;
}
else{
if(b>c) cout<<b<<endl;
else cout<<c<<endl;
}
}
return 0;
}五个数如何只通过六次比较找出中位数
最新推荐文章于 2025-02-15 22:33:17 发布
本文介绍了一种简单的五数排序算法实现方法,通过比较和交换的方式确保五个输入数字中的中间值能够被正确找出。该算法首先对五数进行部分排序,然后基于条件判断输出正确的中间值。
856

被折叠的 条评论
为什么被折叠?



