码迷,mamicode.com
首页 > 其他好文 > 详细

hdu1070

时间:2017-01-21 21:22:00      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:ring   struct   void   int   mil   return   clu   and   tmp   

#include <stdio.h>
#include <string.h>
struct milk{
char brand[128];
int price;
int volume;
double value;
}a[100];
int main(void){
int i,t,n,d;
struct milk tmp;
scanf("%d",&t);
while (t--){
scanf("%d",&n);
for (i=0; i<n; i++){
scanf("%s %d %d",a[i].brand,&a[i].price,&a[i].volume);
d = a[i].volume/200;
if (d==0)
a[i].value = 3.4e+38; // 小于200毫升则费用最高
else if (d<=5)
a[i].value = (double)a[i].price/d;
else
a[i].value = (double)a[i].price/5;
}
tmp = a[0];
for (i=1; i<n; i++)
if (a[i].value<tmp.value)
tmp = a[i];
else if (a[i].value==tmp.value && a[i].volume>tmp.volume)
tmp = a[i];
printf("%s\n",tmp.brand);
}
return 0;
}

hdu1070

标签:ring   struct   void   int   mil   return   clu   and   tmp   

原文地址:http://www.cnblogs.com/wangkun1993/p/6337656.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!