解题思路:
做完菜之后要减去用掉的数量
注意事项:
参考代码:
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语言程序设计教程(第三版)课后习题6.5 (Java代码)浏览:1123 |
蓝桥杯历届试题-九宫重排 (C++代码)浏览:2783 |
P1001 (C语言代码)浏览:801 |
C语言训练-求函数值 (C语言代码)浏览:580 |
WU-拆分位数 (C++代码)浏览:785 |
【蟠桃记】 (C语言代码)浏览:1034 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:621 |
1024题解浏览:808 |
C语言程序设计教程(第三版)课后习题10.7 (用指针求解)浏览:1475 |
杨辉三角 (C语言代码)浏览:679 |