解题思路:
做完菜之后要减去用掉的数量
注意事项:
参考代码:
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 人评分
小九九 (C语言代码)浏览:817 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:640 |
钟神赛车 (C++代码)浏览:864 |
C语言程序设计教程(第三版)课后习题5.7 (C++代码)浏览:846 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:512 |
2005年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:582 |
简单的a+b (C语言代码)浏览:596 |
【计算球体积】 (C语言代码)浏览:1101 |
一元一次方程 (C语言代码)浏览:4063 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:582 |