分支-09. 分段计算居民水费

 1 /*
 2  * Main.c
 3  *B9-分支-09. 分段计算居民水费(10)
 4  *  Created on: 2014年5月28日
 5  *      Author: Boomkeeper
 6  */
 7 
 8 #include <stdio.h>
 9 #include <stdlib.h>
10 
11 int main()
12 {
13     float water_consuption=0;
14     float* pw=&water_consuption;
15 
16     scanf("%f",pw);
17 
18     if(*pw<0)
19         exit(0);
20 
21     if(*pw>=0 && *pw<=15)
22         printf("%.2f
",(4*(*pw))/3);
23 
24     if(*pw>15)
25         printf("%.2f
",(2.5*(*pw)-17.5));
26 
27     return 0;
28 }

 测试通过

原文地址:https://www.cnblogs.com/boomkeeper/p/B9.html