Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

第一次用map,总是compile Error ,请大牛们帮忙改改!!!

Posted by zxxb at 2008-09-08 20:01:59 on Problem 2418
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<map>
using namespace std;
int main()
{
    map<string,int>coll;
    map<string,int>::iterator pos;
    char s[35];
    int n=0;
    while(gets(s)!=NULL)
    {   
        ++n;
        pos=coll.find(s);
        if(pos!=coll.end())
        pos->second++;
        else
        {
           coll.insert(pair<string,int>(s,1));
        }
    }
    for(pos=coll.begin();pos!=coll.end();++pos)
      printf("%s %.4lf\n",(pos->first).c_str(),(100*pos->second)/(double)n);
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator