[Loops]D. Liang 4.10 Finding numbers divisible by 5 and 6.c

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;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值