| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
第一次用map,总是compile Error ,请大牛们帮忙改改!!!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator