1 Star 0 Fork 0

teenboi/CCCC

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
74.MarxMathProblem.cpp 1.15 KB
一键复制 编辑 原始数据 按行查看 历史
teenboi 提交于 2026-01-06 18:35 +08:00 . 马克思手稿中的数学问题
#include <stdio.h>
int main() {
int x, y, z, count = 0;
puts("***************************************************");
puts("* This program is to solve an interesting math question in *");
puts("* Karl Marx's manuscript. *");
puts("* The Problem is as follows: 30 persons spent 50 yuan in a *");
puts("* restaurant, among them, each man spent 3 yuan, each woman *");
puts("* spent 2 yuan, and each child spent 1 yuan. The question is *");
puts("* how many men, women and children are there? *");
puts("***************************************************");
puts(" >> The solutions are:");
printf(" No. Men Women Children\n");
printf("---------------------------------------\n");
for (x = 0; x <= 10; x++) {
y = 20 - 2 * x;
z = 30 - x - y;
if (3 * x + 2 * y + z == 50 && y >= 0 && z >= 0) {
printf(" <%2d> %2d %2d %2d\n", ++count, x, y, z);
}
}
printf("---------------------------------------\n");
printf(" Press Enter to quit...");
getchar();
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/teenboiii/cccc.git
git@gitee.com:teenboiii/cccc.git
teenboiii
cccc
CCCC
master

搜索帮助