ZOJ Problem Set - 1005 - Jugs

it2022-05-08  1

https://www.cnblogs.com/devymex/archive/2010/08/04/1792288.html

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int A; int B; int goal; int nowA, nowB; while(input.hasNext()) { A = input.nextInt(); B = input.nextInt(); goal = input.nextInt(); nowA = 0; nowB = 0; while(nowB != goal) { if(nowA == 0) { System.out.println("fill A"); nowA = A; } if(nowB == B) { System.out.println("empty B"); nowB = 0; } nowB += nowA; nowA = 0; if(nowB > B) { nowA = nowB - B; nowB = B; } System.out.println("pour A B"); } System.out.println("success"); } } }

 

转载于:https://www.cnblogs.com/NEU-2015/p/8410951.html

相关资源:数据结构—成绩单生成器

最新回复(0)