代码拉取完成,页面将自动刷新
#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;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。