杭电1070题

#include <iostream>
#include <string>
#include <vector>
using namespace std;
//注意使用结构体来表示牛奶
struct struct_milk
{
 string brand;
 double price;
 double volumn;
 int day;
 double day_price;
};
int main()
{
 int case_num;
 cin>>case_num;
 for(int i=0;i<case_num;i++)
 {
  int num;
  vector<struct_milk> vec_milk;
  cin>>num;
  for(int i=0;i<num;i++)
  {
   struct_milk milk;
   cin>>milk.brand>>milk.price >>milk.volumn ;
   milk.day = milk.volumn /200;
   if(milk.day >5)
   {
    milk.day_price = milk.price /5;
   }
   else
    milk.day_price = milk.price /milk.day ;
   if(milk.volumn >200)
    vec_milk.push_back (milk);
  }
  struct_milk small_milk = vec_milk[0];
  for(int n=1;n<vec_milk.size ();n++)
  {
   if(vec_milk[n].day_price  < small_milk.day_price  )
   {
    small_milk = vec_milk[n];
   }
   else if(vec_milk[n].day_price == small_milk.day_price )
   {
    if(vec_milk[n].volumn >small_milk.volumn )
    {
     small_milk = vec_milk[n];
    }
   }
  }
  cout<<small_milk.brand <<endl;
 }
 return 0;
}

你可能感兴趣的:(杭电)