CF1760A

题意

\(T\) 组数据,每组数据给 \(3\) 个数,要求选出既不是最大值也不是最小值的那个数。

做法

这题由于十分简单,因此各种做法均可通过。最朴素的做法为比较出最大值和最小值,然后对三个数依次判断,找出符合条件的那个数即可。

Code

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		int a,b,c,d,e;
		cin>>a>>b>>c;
		d=max(a,max(b,c));
		e=min(a,min(b,c));
		if(a!=d&&a!=e) cout<<a<<endl;
		if(b!=d&&b!=e) cout<<b<<endl;
		if(c!=d&&c!=e) cout<<c<<endl;
	}
	return 0;
}
posted @ 2024-01-20 17:47  liyilang2021  阅读(2)  评论(0编辑  收藏  举报