小I的小姐姐

小 I 的小姐姐

Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description

小 I 去天津玩啦,一路上,他跟他的同学发生了许多有趣的事。

当他们路过天津外国语学院时,他发现了许多小姐姐,他眼花缭乱,甚至不知道该去找哪个小姐姐聊天。

怎么办怎么办!

于是他想到了你,他拍了一张照片给你,你发现照片里一共有 n 个小姐姐(序号从 0 到 n - 1),每个小姐姐都有自己的风格,可以按特征划分出 3 个特征值  w1 , w2 , w3 ,你知道小 I 特别喜欢 w1 特征值高的小姐姐,不太看重 w3 ,于是你对于每个特征都赋予一个权重,分别对应为0.7 0.2 0.1,你能帮小 I 找出来他发来的这张照片里他最喜欢的小姐姐吗?

Input

多组输入,对于每组输入:

  • 第一行给出 n (n <= 5000) ,之后有 n 行数。
  • 每行数有三个数 w1, w2, w3,表示三个特征值。

所有整数及结果都在整型范围内,不存在权值和相等的情况。

Output

n 个小姐姐中权值和最高的序号。

Sample Input

3
1  5 10
5 1 10
10 5 1

Sample Output

2

Hint

 

Source

【2017级《程序设计基础(B)II》期末上机考试】IceCapriccio
 

#include <stdio.h>
#include <stdlib.h>
struct xiaojiejie
{
int w1,w2,w3;
double sum;
}st[5001],t;
int main()
{
int n,i;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<=n-1;i++)
{
scanf("%d %d %d",&st[i].w1,&st[i].w2,&st[i].w3);
st[i].sum=st[i].w1*0.7+st[i].w2*0.2+st[i].w3*0.1;
}
double max=st[0].sum;
int p=0;
for(i=1;i<=n-1;i++)
{
if(st[i].sum>max)
{
max=st[i].sum;
p=i;
}
}
printf("%d\n",p);
}

return 0;
}

猜你喜欢

转载自www.cnblogs.com/xiaolitongxueyaoshangjin/p/12031192.html