Description
Write a program that displays all the numbers from 100 to 1000, ten numbers per line, which are divisible by 5 and 6.
Input
None.
Output
You should specify the width of each number’s print field to 5, and justify the output to the left.
The numbers in one line are separated by a space and there is no space at the end of the line.
// Date:2020/3/13
// Author:xiezhg5
#include<stdio.h>
int main(void)
{
int i,j=0;
for(i=100;i<=1000;i++) //遍历100到1000的所有整数
{
if(i%30==0) //同时能被5和6整除的数就是能被30整除的数
{
printf("%-5d ",i);
j++; //j是计数变量
}
//每输出十个有效数字就换行输出
//防止出现未找到数字也换行的情况
if((j%10==0)&&(i%30==0))
printf("\n");
}
return 0;
}