zoukankan      html  css  js  c++  java
  • sicily 1093 Air Express

    水水,注意等于的情况和输出格式...

     1 #include <bits/stdc++.h>
     2 
     3 using namespace std;
     4 
     5 int w[5];
     6 int r[5];
     7 
     8 int main()
     9 {
    10     int n;
    11     int count=0;
    12     while(cin >> w[0])
    13     {
    14         
    15         
    16         cin >> r[0];
    17         for(int i=1; i<3; i++)
    18             cin >> w[i] >> r[i];
    19         cin >> r[3];
    20     
    21         count++;
    22         cout << "Set number " << count << ":" << endl;
    23         int m;
    24         while(cin >> m, m)
    25         {
    26             int flag=1;
    27             int i;
    28             if(m > w[2])
    29             {
    30                 cout << "Weight (" << m << ") has best price $" << m*r[3] << " (add " << 0 << " pounds)" << endl;
    31                 continue;
    32             }
    33             for(i=0; i<3; i++)
    34             {
    35                 if(m <= w[i] && (w[i]+1)*r[i+1] < m*r[i])
    36                 {
    37                     cout << "Weight (" << m << ") has best price $" << (w[i]+1)*r[i+1] << " (add " << w[i]+1-m << " pounds)" << endl;
    38                     break;
    39                 }
    40                 else if(m <= w[i] && (w[i]+1)*r[i+1] >= m*r[i])
    41                 {
    42                     cout << "Weight (" << m << ") has best price $" << m*r[i] << " (add " << 0 << " pounds)" << endl;
    43                     break;
    44                 }
    45             }
    46         }
    47         cout << endl;
    48     }
    49     return 0;
    50 }
  • 相关阅读:
    泛型的内部原理:类型擦除以及类型擦除带来的问题
    Redis的那些最常见面试问题
    线程池全面解析
    对线程调度中Thread.sleep(0)的深入理解
    集群环境下Redis分布式锁
    3.8
    3.7
    3.6任务
    3.5任务
    3.4
  • 原文地址:https://www.cnblogs.com/dominjune/p/4428341.html
Copyright © 2011-2022 走看看