Chinaunix首页 | 论坛 | 博客
  • 博客访问: 157639
  • 博文数量: 76
  • 博客积分: 1513
  • 博客等级: 上尉
  • 技术积分: 755
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-25 15:15
文章分类

全部博文(76)

文章存档

2012年(2)

2011年(74)

我的朋友

分类: C/C++

2011-11-25 21:16:59

/*原文如下:

While the rest of the northern hemisphere was thrown into chaos by the recent cold snap, conditions were perfect this week in Harbin, northeast China, where giant buddhas, skyscrapers and even the Sphinx have been rendered in ice.*/

  1. #include<iostream>

  2. #include<string>

  3. #include<map>

  4. #include<fstream>

  5. using namespace std;

  6. int main()

  7. {

  8.     map<string,int> imap;

  9.     string word;

  10.     ifstream input;

  11.     input.open("test.txt");

  12.     while(input>>word)

  13.     {

  14.                       imap[word]++;

  15.     }

  16.     for(map<string,int>::const_iterator itr=imap.begin();itr!=imap.end();itr++)

  17.     {

  18.                                        if((*itr).first.size()<=7)

  19.                                         cout<<(*itr).first<<"\t\t"<<(*itr).second<<endl;

  20.                                         else

  21.                                          cout<<(*itr).first<<"\t"<<(*itr).second<<endl;

  22.     }

  23.     getchar();

  24.     return 0;

  25. }

/*Output:

China,          1

Harbin,         1

Sphinx          1

While           1

and             1

been            1

buddhas,        1

by              1

chaos           1

cold            1

conditions      1

even            1

giant           1

have            1

hemisphere      1

ice.            1

in              2

into            1

northeast       1

northern        1

of              1

perfect         1

recent          1

rendered        1

rest            1

skyscrapers     1

snap,           1

the             4

this            1

thrown          1

was             1

week            1

were            1

where           1


*/

阅读(865) | 评论(0) | 转发(0) |
0

上一篇:arc second & radians

下一篇:stat( ) 函数

给主人留下些什么吧!~~