程序设计思想:先将3个数字从小到大排序,然后选出最大的和次大的数字,如果这两个数字都大于平均数,那么就是输出是优越数,否则,就不是。
程序代码:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
int main()
{
int n;
int a,b,c;
while(cin>>n)
{
int flag=0;
while(n--)
{
int t;
cin>>a>>b>>c;
if(a<b)
{
t=a;
a=b;
b=t;
}
if(a<c)
{
t=a;
a=c;
c=t;
}
if(b<c)
{
t=b;
b=c;
c=t;
}
int j=(a+b+c)/3;
if(a>j && b>j)
flag=1;
if(flag==1)
{
cout<<"Yes"<<endl;
}
else
{
cout<<"No"<<endl;
}
}
}
return 0;
}
Problem Description
给定3个数,如果有两个数大于他们的平均数则称这组数为优越数。(定义纯属虚构)
Input
输入第一行是一个整数: 表示测试数据的组数。
对于每组测试数据,仅一行3个整数。
Output
对于每组输入数据输出一行,判断它是否为一组优越数,如果是输出“Yes”(输出不包括引号),否则输出“No”。
Example Input
2 1 2 3 1 4 4
Example Output
No Yes