Problem Description

有一家店正在進行促銷,只要客人買10個餅乾和2個蛋糕就多送1盒巧克力,請以程式輸出最後應給予的物品數量。

Input Format

每組輸入為一行,含有3個整數,分別代表餅乾、巧克力和蛋糕,以空白分隔。

Output Format

請輸出應給予之商品數量。

Sample Input

12     6     3

Sample Output

12 個餅乾,7 盒巧克力,3 個蛋糕。


-----*Problem from【ZeroJudge, An Online Judge System For Beginners

 

My Answer

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
#include<iostream>
using namespace
std;
int main(void
)
{
   int
cookie, chocolate, cake;
   while
(cin>>cookie>>chocolate>>cake){
      if
(cookie>=10 && cake>=2){
         if
((cookie/10)>=(cake/2)) chocolate+=(cake/2);
         else
chocolate+=(cookie/10);
     
}
      cout<<cookie<<
" 個餅乾,"
;
      cout<<chocolate<<" 盒巧克力,"
;
      cout<<cake<<" 個蛋糕。"
<<endl;
  
}
   return
0;
}


 


arrow
arrow
    全站熱搜

    兔老大 發表在 痞客邦 留言(0) 人氣()