编辑代码

#include <stdio.h>

void solveChickenProblem() {
    int x, y, z;
    int count = 0;

    // 使用三重循环遍历所有可能的组合
    for (x = 0; x <= 20; x++) {
        for (y = 0; y <= 33; y++) {
            for (z = 0; z <= 100; z++) {
                if (x + y + z == 100 && 5 * x + 3 * y + z / 3 == 100 && z % 3 == 0) {
                    printf("方案%d:鸡翁%d只,鸡母%d只,鸡雏%d只\n", ++count, x, y, z);
                }
            }
        }
    }
}

int main() {
    printf("百钱百鸡问题的解决方案如下:\n");
    solveChickenProblem();

    return 0;
}