TOJ 4349: The Tallest in the Class

    xiaoxiao2021-03-27  24

    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; }
    转载请注明原文地址: https://ju.6miu.com/read-664424.html

    最新回复(0)