/* 功能:渔夫打鱼*/*渔夫出海大鱼,收获若干1.渔夫卖掉一半的鱼,然后送给邻居的海伦 3 条。2.渔夫又卖掉剩下的鱼的 3 分之 2,自己又吃了一条3.海伦来看渔夫,问他那天打了多少鱼,渔夫数了数,家里还剩下 4 条,渔夫对海伦怎么说呢?*/package com.xiaoqiang;public class Fishman public static void main(String args) calcFish();private static void calcFish() int total = 8;/至少有 8 条=邻居的海伦 3 条+ 又吃了一条 + 剩下 4 条int left = 0;do int sold = total / 2;/第一次卖掉一般剩下的int firstLeft = sold - 3;/送掉邻居海伦剩下的if(firstLeft % 3 = 0)left = firstLeft/3 - 1;/ 三分之一里面-吃掉的一条if(left = 4 )System.out.println(“共有“ + total + “ 鱼“);total += 2;/刚开始能平均 2 份,因此鱼数必定是偶数,步长为 2 while (left != 4);