码迷,mamicode.com
首页 > 编程语言 > 详细

uva-10420-排序

时间:2017-07-16 18:22:16      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:ret   using   maps   open   string   code   end   lin   统计   

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

#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;
}

 

uva-10420-排序

标签:ret   using   maps   open   string   code   end   lin   统计   

原文地址:http://www.cnblogs.com/shuiyonglewodezzzzz/p/7191111.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!