c语言百马百担的while
时间: 2023-11-27 10:02:24 浏览: 97
以下是C语言百马百担的while循环实现方法:
```c
#include <stdio.h>
#include <stdlib.h>
int main()
{
int Bh = 3, Mh = 2;
int a = 1, b = 1, c = 1;
double Lh = 0.5;
while (a <= 33)
{
b = 1;
while (b <= 50)
{
c = 100 - a - b;
if (((a*Bh) + (b*Mh) + (c*Lh)) == 100)
{
printf("大马有%d只,中马有%d只,小马有%d只\n", a, b, c);
}
b++;
}
a++;
}
system("pause");
return 0;
}
```
阅读全文