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

习题2-2 阶梯电价

作者:互联网

#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,double,电价,阶梯,cost,习题,include
来源: https://www.cnblogs.com/ytmsnzy/p/16587870.html