TOJ 4349: The Tallest in the Class

4349: The Tallest in the Class

Description

We want to know who is the tallest student in our class. But student’s height is used a different unit of measurement, either
metres(m), decimeteres(dm), centimetres(cm), or millimetres(mm).
Your job is to find out the names of the tallest student in our class.

Input

There are multiple cases.
The first line of each case is an integer n, 0

 #include<iostream>
 #include<map>
 #include<string>
 #include<cmath>
 using namespace std;
 int main(){
    int t;
    while(~scanf("%d",&t)){
        map<string,double>m;
        double ma=0;
        while(t--){
            double d;
            string s,c;
            cin>>s>>d>>c;
            if(c=="cm")
            d*=10;
            else if("dm"==c)
            d*=100;
            else if("m"==c)
            d*=1000;
            if(m[s]!=0)
            s="#"+s;
            m[s]=d;
            if(ma<d)ma=d;
        }
        map<string,double>::iterator it;
        for(it=m.begin();it!=m.end();it++){ 
            if(fabs(it->second-ma)<1e-7){
            string str=it->first;
            if(str[0]=='#')
        str.erase(0,1);
            cout<<str<<endl; }
        }
        cout<<endl;
     }
    return 0;
 } 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值