UVA 10226 Hardwood Species






#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,l,m,n;
    double v;
    map<string,int>a;
    map<string,int>::iterator it=a.begin();
    string st,s;
    char c,d;
    //freopen("10226.txt","r",stdin);
    //freopen("10226out.txt","w",stdout);
    cin>>n;

    for(i=1;i<=n;i++)
    {
        j=0;
        k=0;
        a.clear();
        if(i==1)
        {
            cin.ignore();
            cin.ignore();
        }
        while(getline(cin,st))
        {
            if(st=="")
            {
                break;
            }
            else
            {
                a[st]++;
                j++;

            }


        }


            for(it=a.begin();it!=a.end();it++)
            {
                cout<<it->first<<" ";
                v=((double)(it->second)/(double)j)*100.00;
                printf("%0.4lf\n",v);
               
            }
            if(i!=n)
            {
                cout<<endl;
            }

    }

    return 0;
}

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment