这是c代码,相应语句改一改就好了。
#include
#define MALE_MONKEY 5
#define FEMALE_MONKEY 4
#define LITTLE_MONKEY 2
#define TOTAL 50
int main()
{
for (int i=0; i
for (int j=0;j
for (int k=0;k
if (TOTAL == i*MALE_MONKEY + j*FEMALE_MONKEY + k*LITTLE_MONKEY && 20==i+j+k)
printf ("MALE_MONKEY: %d FEMALE_MONKEY: %d LITTLE_MONKEY: %d\n",i,j,k);
}
}
}
}
#include
using namespace std;
int main()
{
int gh,mh,xh;
for(gh=1;gh<=18;gh++)
{
for(mh=1;mh<=18;mh++)
{
for(xh=1;xh<=18;xh++)
if((gh+mh+xh==20)&&(10*gh+8*mh+xh==100))
cout<<"公猴有:"<
}
return 0;
}
ndndndgnhfhfhdghgg