标签:
//百鸡百钱 公鸡2文,母鸡1文,小鸡0.5文 int count = 0; int gong = 0; while (gong<=50) { int mu = 0; while(mu<=100) { int xiao = 0; while(xiao<=200) { if(gong+mu+xiao==100&&2*gong+mu+0.5*xiao==100) { count++; Console.WriteLine("第"+count+"种组合,公鸡:"+gong+"只,母鸡:"+mu+"只,小鸡:"+xiao+"只"); } xiao++; } mu++; } gong++; } Console.WriteLine("共有"+count+"种组合!"); Console.ReadLine();
标签:
原文地址:http://www.cnblogs.com/fengsantianya/p/5459983.html