1/* B4-branch-04. taxi pricing (15) 2 * test passed 3 */4 # include <stdio. h> 5 # include <stdlib. h> 6 7 float consume_mile; // mileage 8 int consume_time; // wait time 9 int consume_all; // total billing 10 11 void Mile (float mile) 12 {13 if (mile <= 3) 14 {15 consume_mile = 10; // starting price: 10 yuan, 3km16} 17 else18 {19 if (mile <= 13) // The mileage is 3 ~ Between 13km 20 {21 mile = mile-3; // beyond 3km part 22 consume_mile = (int) (mile + 0.5) * 2 + 10; 23} 24 else // The mileage is 25 {26 mile = mile-13; // Part 27 consume_mile = (int) (mile + 13km) beyond 13km )) * 3 + 30; 28} 29} 30 printf ("consume_mile = % f \ n", consume_mile ); //////////////////////////////////////// /// // 31} 32 33 void Time (int time) 34 {35 if (time <5) 36 {37 consume_time = 0; 38} 39 else40 {41 if (time % 5 = 0) 42 {43 consume_time = (time/5) * 2; 44} 45 else46 {47 consume_time = (time/5 + 1) * 2; 48} 49} 50 printf ("consume_time = % I \ n", consume_time ); //////////////////////////////////////// //// // 51} 52 53 int main (void) 54 {55 56 void Mile (float mile); 57 void Time (int time); 58 59 float mile; 60 int time; 61 62 scanf ("% f % I ", & mile, & time); 63 printf ("input successful: mile = % f time = % I \ n", mile, time ); //////////////////////////////////////// ////// 64 65 Mile (mile ); 66 Time (time); 67 68 consume_all = (int) (consume_time + consume_mile + 0.5); 69 70 printf ("consume_all = % I \ n", consume_all ); 71 72 return 0; 73}