首页 > 其他分享 >习题2-2 阶梯电价

习题2-2 阶梯电价

时间:2022-08-15 12:34:39浏览次数:73  
标签:lf int 电价 阶梯 习题 include

#include<stdio.h>
int main() {
	double cost, n;

	scanf("%lf", &n);
	if(n<0) {
		printf("Invalid Value!\n");
	} else if(n<=50) {
		cost = n*0.53;
		printf("cost = %.2f\n", cost);
	} else {
		cost = 50*0.53+(n-50)*(0.53+0.05);
		printf("cost = %.2f\n", cost);
	}

	return 0;
}

 

标签:lf,int,电价,阶梯,习题,include
From: https://www.cnblogs.com/ytmsnzy/p/16587870.html

相关文章