http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=2972 這題先把綠茶跟麵包金額先算出來,然後再判斷有送幾個餅乾最後相減加上餅乾錢就是答案了!
#include<stdio.h>
int main(){
int x,y,z,tot=0,count=0;
scanf("%d%d%d0",&x,&y,&z);
tot=x*20+y*25;
while(1){
if(x-3>=0&&y-2>=0){
x-=3;
y-=2;
count++;
}
else
break;
}
tot+=(z-count)*30;
printf("%d\n",tot);
/*
題目:[C_MM116-易] 買東西
作者:1010
時間:西元 2016 年 7 月 */
}