首页 > 学院 > 开发设计 > 正文

泊松分酒

2019-11-06 08:05:21
字体:
来源:转载
供稿:网友
import java.util.Scanner;public class Main {	static int A,B,C;	public static void main(String[] args) {		Scanner s=new Scanner(System.in);		int[] t=new int[7];		System.out.PRint("请输入酒瓶容量A,B,C各个瓶有多少酒a,b,c及目标aim");		for(int i=0;i<7;i++)		{			t[i]=s.nextInt();		}		A=t[0];		B=t[1];		C=t[2];		int a=t[3];		int b=t[4];		int c=t[5];		int aim=t[6];		if(a+b+c>=aim)		{			bosong(a,b,c,aim);		}		else		{			System.out.print("不可能");		}	}	public static void bosong(int a,int b,int c,int aim)	{		System.out.println(a+","+b+","+c);		if(a==aim||b==aim||c==aim)		{			return;		}		if(b==0&&c==0)		{			bosong(a-B>0?a-B:0,a-B>0?B:a,c,aim);		}		else if(b>0&&c==0)		{			bosong(a,b-C>0?b-C:0,b-C>0?C:b,aim);		}		else if(b>0&&c>0&&c<C)		{			bosong(a,b>C-c?b-C+c:0,b>C-c?C:b+c,aim);		}		else if(c==C)		{			bosong(A-a>C?a+c:A,b,A-a>C?0:A-a,aim);		}		else if(a!=0&&b!=B)		{			bosong(a>B-b?a-B+b:0,a>B-b?B:b+a,c,aim);		}		else		{			System.out.print("不可能");		}	}}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表