5 green red blue red red 3 pink orange pink 0
red pink
#include <cstdio> #include <iostream> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <queue> #include <vector> #include <map> using namespace std; #define ll long long map<string, int>mp; struct node { string s; int num; } r[1000+8]; int n; string si; bool cmp(node a, node b) { return a.num>b.num; } int main() { while(~scanf("%d", &n) && n != 0) { mp.clear(); for(int i = 0; i<n; i++) { cin>>si; if(mp[si])mp[si]++; else mp[si] = 1; } int id = 0; for(map<string, int>::iterator ii = mp.begin(); ii != mp.end(); ii++) { r[id].s = ii->first; r[id].num = ii->second; id++; } sort(r, r+id, cmp); cout<<r[0].s<<endl; } return 0; }
SDNU 1125.Let the Balloon Rise
原文:https://www.cnblogs.com/RootVount/p/10981994.html