买鸡

package book;
/** * 公鸡3元,母鸡5元,小鸡3只1元 * 问:100元买100只鸡 * @author soft01 * */
public class Book {
  public static void main(String[] args) throws Exception {
    int c;
    for(int a=1;a<=50;a++){
      for(int b=1;b<=33;b++){
        c=100-a-b;
        if((a*5+b*3+c/5==100) && (a+b+c==100)) {
          System.out.println("母鸡:"+a+"公鸡:"+b+"小鸡:"+c);
        }
      }
    }
  }
}

原文地址:https://www.cnblogs.com/ahaijava/p/9993569.html