ACM (TJU) : 3005


// http://acm.tju.edu.cn/toj/showp3005.html

#include <stdio.h>
#include <string.h>

int main ()
{
    int dataset;
    scanf ("%d", &dataset);
    int cases = 0;

    while ( dataset-- ) {
        double input;
        char standard [5];

        scanf ("%lf %s", &input, standard);

        if ( !strcmp (standard, "kg") )
            printf ("%d %.4lf lb", ++cases, input * 2.2046);

        else if ( !strcmp (standard, "l") )
            printf ("%d %.4lf g", ++cases, input * 0.2642);

        else if ( !strcmp (standard, "lb") )
            printf ("%d %.4lf kg", ++cases, input * 0.4536);

        else if ( !strcmp (standard, "g") )
            printf ("%d %.4lf l", ++cases, input * 3.7854);

        printf ("\n");
    }

    return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s