Uva 10226 Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long t;
    cin >> t;
    getchar();
    getchar();

    while(t--)
    {
        string st;
        map<string, int>mp;
        map<string, double>f;
        long c = 0, ct = 0;
        while(getline(cin, st) && st != "")
        {
            mp[st]++;
            c++;
        }
        for(auto it=mp.begin(); it != mp.end();it++)
        {
            string s = it->first;
            int dt = it->second;
            double db = ((double)dt * 100.00)/(double)c;
            f[s] = db;
        }

        cout << showpoint;
        cout << fixed;
        cout << setprecision(4);

        for(auto it=f.begin(); it != f.end(); it++)
        {
            cout << it->first << " " << it->second << "\n";
        }
        if(t > 0)
            cout << "\n";
    }

    return 0;
}

Comments