http://acm.hdu.edu.cn/showproblem.php?pid=1985

小学计算题

View Code
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    for(int cas=1;cas<=t;cas++)
    {
        double n;
        string d;
        cin >> n >> d;
        if(d=="kg")
            printf("%d %.4lf lb\n",cas,n*2.2046);
        else if(d=="lb")
            printf("%d %.4lf kg\n",cas,n*0.4536);
        else if(d=="g")
            printf("%d %.4lf l\n",cas,n*3.7854);
        else if(d=="l")
            printf("%d %.4lf g\n",cas,n*0.2642);
    }
    return 0;
}