心如止水
Je n'ai pas le temps
posts - 400,comments - 130,trackbacks - 0

女孩们的名字没有什么用,用map<string,int>对象记录每个国家出现的次数即可。
以下是我的代码:

#include<iostream>
#include
<string>
#include
<map>
#include
<cstdio>
using namespace std;
const int kMaxn(2007);

int main()
{
    
/*
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);
    //
*/

    
int n;
    cin
>>n;
    map
<string,int> r;
    
for(int i=1;i<=n;i++)
    {
        
string country,t;
        cin
>>country;
        r[country]
++;
        getchar();
        getline(cin,t);
    }

    
for(map<string,int>::iterator i=r.begin();i!=r.end();i++)
        cout
<<i->first<<" "<<i->second<<endl;

    
return 0;
}
posted on 2011-04-08 23:35 lee1r 阅读(1077) 评论(0)  编辑 收藏 引用 所属分类: 题目分类:数据结构题目分类:排序

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理