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 killua_hzl at 2008-07-20 15:19:50 on Problem 1677
#include<iostream>
#include<map>
#include<string>
using namespace std;

int n,m;
string namelist[10];
char step[]=" !";


void inputname()
{
	int i;
	for(i=1;i<=n;i++)
		cin>>namelist[i];
}

void fun(char s[])
{	
	map<string,int> mp;
	int word=0;
	char* t;
	t=strtok(s,step);
	bool keyword=false;
	while(t!=NULL)
	{
		word++;
		if(t[0]>='A'&&t[0]<='Z') t[0]=t[0]-'A'+1;
		if(!strcmp(t,"beautiful")||!strcmp(t,"pretty")||!strcmp(t,"lovely"))
			keyword=true;
		mp[(string)t]++;
		t=strtok(NULL,step);
	}
	int i;
	int b[10],k=0;
	for(i=1;i<=n;i++)
	{
		if(mp[namelist[i]]>0) b[++k]=i;
	}
	
	if(k==0) cout<<"All: ";
	else
	{
		for(i=1;i<k;i++)
			cout<<namelist[b[i]]<<" ";
		cout<<namelist[b[i]]<<": ";
	}
	if(word<=9) cout<<"oh"<<endl;
	else
	{
		if(keyword)
		{
			cout<<"xixi"<<endl;
		}
		else
			cout<<"hehe"<<endl;
	}
	mp.clear();
}

int main()
{
//	freopen("pku_1677.in","r",stdin);
	while(scanf("%d %d\n",&n,&m)!=EOF)
	{
		inputname();
		getchar();
		int i;
		char s[1000];
		for(i=1;i<=m;i++)
		{
			gets(s);
			fun(s);
		}
	}
		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