公🐔母🐔小🐔

88 阅读1分钟

挑战100块买100🐔

image.png

#include <stdio.h>

int main() {
    int gj, mj, xj;
    
    for (gj = 0; gj <= 20; gj++) {
        for (mj = 0; mj <= 33; mj++) {
            xj = 100 - gj - mj;
            if ( (5 * gj + 3 * mj + xj / 3 == 100) && (xj % 3 == 0) ) {
                printf("公鸡:%d只,母鸡:%d只,小鸡:%d只\n", gj, mj, xj);
            }
        }
    }
    
    return 0;
}

运行结果如下

image.png