Created
January 7, 2017 01:45
-
-
Save dudelson/894680bf115ca1e853c9508b40dc7a1d to your computer and use it in GitHub Desktop.
My solution for UVA 10226
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include <string> | |
#include <map> | |
using namespace std; | |
map<string, int> m; | |
int n; | |
double trees; | |
string s; | |
int main() { | |
ios_base::sync_with_stdio(false); | |
cin.tie(NULL); | |
cin >> n; getline(cin, s); getline(cin, s); | |
cout << setprecision(4) << fixed; | |
for(int i=0; i<n; i++) { | |
if(i > 0) cout << '\n'; | |
trees = 0; | |
m.clear(); | |
while(getline(cin, s) && s!="") { | |
m[s]++; | |
trees++; | |
} | |
for(map<string, int>::iterator it=m.begin(); it!=m.end(); it++) | |
cout << it->first << " " << (it->second)*100/trees << '\n'; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment