国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

poj2550

2019-11-11 02:01:01
字體:
供稿:網(wǎng)友

Description

Harvard linguistics PRofessor George Kingsley Zipf (1902-1950) observed that the frequency of the kth most common Word in a text is roughly proportional to 1/k. He justified his observations in a book titled Human behavior and the principle of least effort published in 1949. While Zipf's rationale has largely been discredited, the principle still holds, and others have afforded it a more sound mathematical basis. You are to find all the words occurring n times in an English text. A word is a sequence of letters. Words are separated by non-letters. Capitalization should be ignored. A word can be of any length that an English word can be.

Input

Input consists of several test cases. The first line of each case contains a single positive integer n. Several lines of text follow which will contain no more than 10000 words. The text for each case is terminated by a single line containing EndOfText. EndOfText does not appear elsewhere in the input and is not considered a word.

Output

For each test case, output the words which occur n times in the input text, one word per line, lower case, in alphabetical order. If there are no such words in input, output the following line: There is no such word. Leave a blank line between cases.

Sample Input

2In practice, the difference between theory and practice is alwaysgreater than the difference between theory and practice in theory.	- AnonymousMan will occasionally stumble over the truth, but most of thetime he will pick himself up and continue on.        - W. S. L. ChurchillEndOfText

Sample Output

betweendifferencein

will

#include<iostream>#include<sstream>#include<map>using namespace std;int main(){    string s;    int n;    map<string,int>m;    while(cin>>n)    {        m.clear();        while(cin>>s&&s!="EndOfText")        {            for(int i=0;i<s.length();i++)            {                if(isalpha(s[i]))s[i]=tolower(s[i]);                else s[i]=' ';            }            stringstream stream(s);            while(stream>>s)m[s]++;        }        int flag=0;        for(map<string,int>::iterator it=m.begin();it!=m.end();it++)        {            if(it->second==n){                cout<<it->first<<endl;                flag=1;            }        }        if(flag==0)cout<<"There is no such word."<<endl;        cout<<endl;    }    return 0;}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 石棉县| 略阳县| 慈利县| 汕尾市| 柯坪县| 丹东市| 波密县| 郯城县| 裕民县| 泊头市| 屏南县| 平远县| 崇义县| 罗源县| 建平县| 新营市| 白水县| 隆回县| 惠安县| 蓝田县| 正蓝旗| 库尔勒市| 新化县| 新绛县| 大英县| 中西区| 临武县| 桂阳县| 莫力| 双江| 秦安县| 灵石县| 台南市| 五寨县| 兴海县| 陆丰市| 温泉县| 霞浦县| 扶风县| 台东县| 武邑县|