巢穴

about:blank

P2418

可用2叉树.可用快排扫描统计,可直接用map....

#include <map>
#include 
<string>
#include 
<stdio.h>
using namespace std;


int main()
{
        map 
< string , int> tree;
        
char temp[50] ;
        
string str;
        
int total=0;
        
while(gets(temp))
        
{
                str
=temp;
                tree[aaa]
++;
                total
++;
        }

        map
<string,int>::iterator itr;
        
for(itr = tree.begin(); itr != tree.end(); itr++)
        
{
                cout
<<itr -> first<<" ";
                printf(
"%.4lf\n",100*double(itr -> second)/double(total));
        }

        
return 0;
}

posted on 2009-10-15 12:07 Vincent 阅读(112) 评论(0)  编辑 收藏 引用 所属分类: 数据结构与算法


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理