一道不难的C语言编程题

来源:百度知道 编辑:UC知道 时间:2024/06/27 03:51:28
编程:有一袋球(在100~200之间),如果每次取4个,还剩2个;每次取5个,还剩3个;每次取6个,则正好取完,求该袋球的个数。

#include <stdio.h>
void main()
{
int x;
for(x=100;x<=200;x++)
if(x%4==2)
if(x%5==3)
if(x%6==0)
printf("%d\n",x);
}

138或者198

#include <iostream>
using namespace std;
int main(void)
{
int x;
for(x=100;x<=200;x++)
if(x%4==2)
if(x%5==3)
if(x%6==0)
printf("%d\n",x);
return 0;
}

这题书上有类似的嘞~~~~
~~~自己能解决嘞的~~~~~~~~