用c语言求100到300之间能被3和5同时整除的数,要求每行输出五个数。

如题所述

#include <stdio.h>

int main()

{int i,n=0;

for(i=105;i<300;i+=15)

{printf("%5d",i);

if(++n%5==0)

printf("\n");

}

return 0;

}

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-11-29
#include <stdio.h>
int main()
{
int i;
int count = 0;
for(i = 100; i <= 300; i++)
{
if(i % 3 == 0 && i % 5== 0)
{
count ++;
printf("%d ",i);
if(count % 5 == 0)
{
printf("\n");
}
}
}
return 0;
}本回答被网友采纳
第2个回答  2015-11-29
这不难吧追答

用个for循环

用if判断

主要看你%的运用

第3个回答  2021-04-27

相似回答