李凌峰


私信TA

用户名:lilingfeng0822

访问量:3627

签 名:

等  级
排  名 446
经  验 4669
参赛次数 0
文章发表 22
年  龄 0
在职情况 学生
学  校 湖北生物科技职业学院
专  业

  自我简介:

解题思路:
做完菜之后要减去用掉的数量
注意事项:

参考代码:


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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区