zoj 2104 Let the Balloon Rise

来源:互联网 发布:p2p网络摄像头软件app 编辑:程序博客网 时间:2024/05/16 16:13
#include "iostream"#include "string"#include "vector"using namespace std;struct ballons{string color;int count;};int main(){int N, i;vector<ballons> v;vector<ballons>::iterator it;ballons temp;bool tag;while (cin >> N && N){v.clear();for (i = 0; i < N; i++){cin >> temp.color;temp.count = 1;tag = false;for (it = v.begin(); it != v.end(); it++){if ((*it).color == temp.color){(*it).count++;tag = true;}}if (!tag)v.push_back(temp);}int max = 0;string ans;for (it = v.begin(); it != v.end(); it++){if ((*it).count > max){max = (*it).count;ans = (*it).color;}}cout << ans << endl;}}