Posted: Thu Sep 06, 2007 6:51 pm
most probably online-judge doesn't support clear()
could somebody give a specification on the environment of online-judge?ayon wrote:most probably online-judge doesn't support clear()
It does.ayon wrote:most probably online-judge doesn't support clear()
Code: Select all
//Zipf's law
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main(){
int n;
int count=0;
while(cin>>n){
if(count++!=0) cout<<"\n";
string s;
int loop=1;
map<string,int> maps;
while(loop==1){
getline(cin,s,'\n');
s=s+" ";
int i=0;
while(i<s.length()){
string h="";
int val=s[i];
string alias="";
while((val>=65 && val<=90)|| (val>=97 && val<=122)){
if(val>=90) h=h+s[i];
else h=h+char(s[i]+32);
alias=alias+s[i++];
val=s[i];
}
i++;
if(alias=="EndOfText"){
loop=0;
break;
}
maps[h]=maps[h]+1;
}
}
map<string,int>::iterator iter;
iter=maps.begin();
int l=0;
while(iter!=maps.end()){
if(iter->second==n) {
cout<<iter->first<<"\n";
l=1;
}
iter++;
}
if(l==0) cout<<"There is no such word."<<"\n";
maps.clear();
}
return(0);
}
output2
a-a
EndOfText