2025-03-06 22:45:14 +08:00

26 lines
818 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
百马百担有一百匹马驮一百担货大马驮3担中马驮2担两只小马驮1担每匹马都要驮货编程计算大马dm)、中马(zm)、小马(xm)各有多少匹。 使用for循环
结果:
大马有2匹中马有30匹,小马有68匹
大马有5匹中马有25匹,小马有70匹
大马有8匹中马有20匹,小马有72匹
大马有11匹中马有15匹,小马有74匹
大马有14匹中马有10匹,小马有76匹
大马有17匹中马有5匹,小马有78匹
-------------------------------------------------------*/
#include <stdio.h>
void main() {
int dm,zm,xm;
/**********Program**********/
for(dm=1;dm<66;dm++){
for(zm=1;zm<100;zm++){
for(xm=2;xm<200;xm+=2){
if(dm*3+zm*2+xm/2 == 100 && dm+zm+xm==100)
/********** End **********/
printf("大马有%d匹中马有%d匹,小马有%d匹\n",dm,zm,xm);
}
}
}
}