Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

能帮我看一下哪里的问题么,wa:(

Posted by Norton at 2005-08-11 11:55:33 on Problem 2550
#include<iostream>
#include<map>
#include<string>
using namespace std;
typedef map<string,int> myMap;
int main(){
	string s;
	myMap p;
	myMap::iterator ip;
	int n,i,j;
	bool flag;
	char c[50];
	while(cin>>n){
		while(1){
		cin>>s;
		if(s=="EndOfText")break;
		for(i=0,j=0;i<s.size();i++)
			if(s.at(i)>='A'&&s.at(i)<='Z')
			{	c[j]=((char)s.at(i)+32);j++;}
			else if(s.at(i)>='a'&&s.at(i)<='z')
			{	c[j]=s.at(i);j++;}
		if(j!=0)
			c[j]='\0';
		else continue;
		s=c;
		ip=p.find(s);
		if(ip==p.end())
			p.insert(myMap::value_type(s,1));
		else (*ip).second++;
		}
		flag=true;
		for(ip=p.begin();ip!=p.end();ip++)
			if((*ip).second==n)
			{	cout<<(*ip).first<<endl;flag=false;}
		if(flag)cout<<"There is no such word."<<endl;	
		cout<<endl;
		p.clear();
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator