1.1 百钱百鸡问题
源代码 #include<bits/stdc++.h> using namespace std; int main(){ //百钱百鸡 int cock,hen,chicken; for (cock=0;cock<=20;cock++)//控制公鸡数量 for(hen=0;hen<=30;hen++)//控制母鸡数量 for(chicken=0;chicken<=100;chicken++) { chicken=100-cock-hen; if(5*cock+3*hen+chicken/3.0==100) printf("cock=%2d,hen=%2d,chicken=%2d\n",cock,hen,chicken);}