Java面試題:有20塊錢,1塊錢能買一瓶汽水,2個瓶子能換一瓶汽水,3個瓶蓋能換一瓶汽水, 問一共能喝多少瓶汽水。(遞歸)

public class BuySoda { public static void main(String[] args) { BuySoda buy = new BuySoda(); int num = buy.buywater(20, 0, 0); System.out.println("一共能喝" + num + "瓶汽水"); } /* * 建立沒水的方法,傳入三個
相關文章
相關標籤/搜索