菜菜

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

根据国家名字统计人数,然后排序

#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<memory.h>
#include <math.h>
#include<time.h>
#include <stdlib.h>
using namespace std;

struct Node
{
    string key;
    int total;
};
int main()
{
    freopen("d:\\1.txt","r",stdin);
    int n;
    cin>>n;
    map<string,int>maps;
    string str;
    for(int i = 0; i< n;i++)
    {
        cin>>str;
        int j  = maps[str];
        j++;
        maps[str] = j;
        getline(cin,str);
    }
    map<string,int>::iterator iter;
    for(iter = maps.begin(); iter != maps.end(); ++iter)
    {
        cout<<iter->first<<" "<<iter->second<<endl;
    }

    return 0;
}

 

posted on 2017-07-16 17:26  好吧,就是菜菜  阅读(162)  评论(0编辑  收藏  举报