首页 > 其他 > 详细

NYOJ286 动物统计

时间:2014-02-18 16:08:44      阅读:418      评论:0      收藏:0      [点我收藏+]

原题链接

简单题。

附ac代码:

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	vector<string> vec;
	vector<int> inde;
	string str;
	cin >> n;
	while(n--){
		cin >> str;
		vector<string>::iterator fin;
		fin = find(vec.begin(), vec.end(), str);
		if(fin != vec.end()) 
			++inde[fin - vec.begin()];
		else{
			vec.push_back(str);
			inde.push_back(1);			
		}
	}
	//找到最大值
	vector<int>::iterator ite = max_element(inde.begin(), inde.end());
	cout << vec[ite - inde.begin()]
		 << ‘ ‘ << *ite << endl;
	return 0;
}


NYOJ286 动物统计

原文:http://blog.csdn.net/chang_mu/article/details/19399049

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!