百钱买白鸡 C C++ Python

2023-07-28 20:22:19 浏览数 (1)

C

代码语言:javascript复制
#include <stdio.h>
int main()
{
	int cock,hen;
	for(cock=0;cock<=20;cock  )
	for(hen=0;hen<=33;hen  )
	if(5*cock 3*hen (100-cock-hen)*1.0/3==100)
	printf("cock=%d hen=%d chick=%dn",cock,hen,100-cock-hen);
}

C

代码语言:javascript复制
#include <iostream>
using namespace std;
int main()
{
	int cock,hen;
	for(cock=0;cock<=20;cock  )
	for(hen=0;hen<=33;hen  )
	if(5*cock 3*hen (100-cock-hen)*1.0/3==100)
	cout<<"cock="<<cock<<" "<<"hen="<<hen<<" "<<"chick="<<100-cock-hen<<endl;
}

Python

代码语言:javascript复制
for cock in range(21):
    for hen in range(34):
        if 5*cock 3*hen (100-cock-hen)/3==100:
            print("cock=",cock,"hen=",hen,"chick=",100-cock-hen)

0 人点赞