//大马驼2石粮食,中等马驼1石粮食,两头小马驼1石粮食, //要用100匹马,驼100石粮食,该如何分配? int count=0; for (int da = 0; da <= 50;da++ ) { for (int zhong = 0; zhong <= 100;zhong++ ) { for (int xiao = 0; xiao <= 200;xiao++ ) { if(da+zhong+xiao==100&&2*da+zhong+0.5*xiao==100) { count++; Console.WriteLine("第" + count + "种分配方法:大马:" + da + "匹,中等马:" + zhong + "匹,小马:" + xiao + "匹"); } } } } Console.WriteLine("共有" + count + "种方法"); Console.ReadLine();