解题思路:
做完菜之后要减去用掉的数量
注意事项:
参考代码:
import java.util.Scanner; public class 学做菜 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); int d=sc.nextInt(); int a1=0,b1=0,c1=0,d1=0,e1=0; //西红柿炒蛋 while (a>=2&&b>=1&&d>=2) { a-=2; b-=1; d-=2; a1++; } //酸辣鸡 while (a>=1&&b>=1&&c>=1&&d>=1) { a-=1; b-=1; c-=1; d-=1; b1++; } //宫爆鸡 while (c>=2&&d>=1) { c-=2; d-=1; c1++; } //水煮西红柿 while (b>=3) { b-=3; d1++; } while (a>=1&&d>=1) { a-=1; d-=1; e1++; } System.out.printf("%d\n%d\n%d\n%d\n%d",a1,b1,c1,d1,e1); } }
0.0分
0 人评分
WU-链表数据求和操作 (C++代码)浏览:1312 |
【明明的随机数】 (C语言代码)浏览:785 |
1011题解浏览:760 |
1071题解浏览:484 |
1051(奇了怪了)浏览:645 |
2006年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:661 |
简单的a+b (C语言代码)浏览:504 |
【魔板】 (C++代码)浏览:1156 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:480 |
发工资咯 (C语言代码)浏览:792 |