POJ 1326 mileage Bank (water ~)

Source: Internet
Author: User
Tags strcmp

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); }
} 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.