1. 程式人生 > >16.百元買百雞

16.百元買百雞

col style b+ border char pos include blog div

#include <stdio.h>

int main(int argc, char *argv[])
{
    int a,b,c;//a-公雞;b--母雞;c--小雞 
    for(a=0;a<=20;a++)
        for(b=0;b<=33;b++)
            for(c=0;c<=99;c=c+3)
                if(a+b+c == 100)
                    if(c%3 == 0)
                        if(5*a+3*b+c/3 == 100)
                            {
                                printf(
"公雞:%d,母雞:%d,小雞:%d\n",a,b,c); } return 0; } //窮舉法,滿足條件就輸出

16.百元買百雞