The
Description
gives the length of the route, and the economy class is 500 km below 500 km, otherwise the actual mileage is counted. Business class calculates the actual mileage x1.5. First class actual mileage X2. Based on the given flight, find out the total route length
input
Multiple sets of use cases, each set of use cases including multiple voyages, each row represents a voyage, the "departure City destination City actual flight type" mode input, to 0 end each group of use cases, to # end all input
output
for each set of use cases, the total route length
Sample Input
Beijing Tokyo 1329 F
Shanghai Wuhan 433 Y
0
#
Sample Output
3158
solution
Water Title
Note Four Five Enter (int) floor (len+0.5)
Code
#include <stdio.h> #include <string.h> #include <ctype.h> int main () {char s
[100];
int x,i,len,n;
Double m;
Gets (s);
while (strcmp (S, "#")!=0) {n=0;
while (strcmp (S, "0")!=0) {m=0;
Len=strlen (s); for (i=0;i<len;i++)//Get route actual mileage if (s[i]>= ' 0 ' &&s[i]<= ' 9 ') m=m*10+s[i]-' 0
';
if (s[len-1]== ' F ')//business class m*=2;
else if (s[len-1]== ' B ')//First class M+=M/2;
else if (s[len-1]== ' Y ')//Economy class m=m>500?m:500;
n+=m+0.5;//rounding gets (s);
} printf ("%d\n", N);
Gets (s); }
}