| ||||||||||
| 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 | |||||||||
what the hellI keep getting "Wrong Answer" for the code below....I have tested over and over and the output i am getting seems to be correct. any suggestions?
//HARDWOOD SPECIES PROBLEM 2418
#include <stdio.h>
#include <string>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main(void)
{
int total = 0;
int index = 0;
typedef map<std::string, int> NewMap;
NewMap treeList;
std::string str[10000];
char tname[31];
while(scanf(" %[^\n]",tname)!=EOF){
if (treeList.count(tname)==0){
str[index].assign(tname, tname + strlen(tname));
++treeList[str[index]];
index++;
}
else
++treeList[tname];
index++;
total++;
}
NewMap::iterator it_type;
for(it_type = treeList.begin(); it_type != treeList.end(); it_type++)
{
printf("%s %.4lf\n",it_type->first.c_str(),100*(double)(it_type->second)/total);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator