baiqianbaiji

#include   
#include   
#define sum 100  

int moneychicken()  
{  
    int goj = 5;  
    int muj = 3;  
    int go = 1, mu = 1, xiao = 1;  
    for (go = 1; go < 21; go++) {  
        for (mu = 1; mu < 34; mu++) {  
            if ((go*goj + mu*muj + (JI - go - mu) / 3 == sum) && ((sum - go - mu) % 3 == 0)) {  
                printf("公鸡:%d 母鸡:%d 小鸡:%d\n", go, mu, (100 - go - mu));  
            }  
        }  
    }  
}  

int rabbitAndChicken(int head, int foot)  
{  
    printf("鸡:%d, 兔:%d\n", head - ((foot - 22 * head) / 2), ((foot - 22 * head) / 2));  
}  
int main()  
{  
    int head, foot;  
    scanf("%d %d", &head, &foot);  
    moneychicken();  
    rabbitAndChicken(head, foot);  
    return 0;  
}  

结果图片:baiqianbaiji_第1张图片

心得体会:易丢失“}”易忘记定义 ‘muj’函数的调用易错还有分号”;”“)”这些都很容易丢失

你可能感兴趣的:(baiqianbaiji)