今日份

//读取一系列数据,每个数据表示每日的最低温度,然后打印统计的总天数和最低温度在O度以下的天数占总天数的百分比
//scanf()读取温度值,while每迭代一次,就递增计数器增加天数,其中if语句负责判断0度以下的温度并单独相应的天数
#include<stdio.h>
int main()
{
	//变量有哪些cold_days all_days 
	const int FREEZING = 0;
	float temperature;
	int cold_days = 0;
	int all_days = 0;

	printf("Enter the list of daily low temperatures.\n");
	printf("Use Clesius,and enter q to quit.\n");
	while (scanf("%f", &temperature) == 1)
	{
		all_days++;
		if (temperature < FREEZING)
			cold_days++;
	}
	if (all_days != 0)
		printf("%d days total:%0.1f%% were below temperature.\n",
			all_days, 100.0*(float)cold_days / all_days);
	if (all_days == 0)
		printf("No date enter!\n");
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值