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

Re:为什么还是WA啊?(附程序)

Posted by just at 2004-06-28 16:19:43 on Problem 1677
In Reply To:Re:为什么还是WA啊?(附程序) Posted by:slick at 2004-06-28 08:54:21
还是不行,ft死了

#include<iostream.h>
#include<stdio.h>
#include<memory.h>
#include<string.h>
void main()
{
	int n,m,flag,ok,toto[10],total,i,j;
	char name[10][200] ;
	char word[300],wish[300] ;
	cin >> n >> m ;
	for( i = 0 ; i <= n ; i++ )
		cin.getline( name[i] ,sizeof(name[i])) ;
	while( m-- )
	{		
		cin.getline( wish,sizeof(wish)) ;
		j = 0 ;
		for( i = 0 ;i < strlen(wish) ; i++ )
		{
			if ( wish[i] != ' ' && wish[i] != '!' )
				word[i-j] = wish[i] ;
			else 
			{	
				word[i-j] = '\0' ;
				while(wish[i] == ' ' ||  wish[i] == '!' ) 
					i++ ;
				j = i ;
				break;
			}
		}
		memset( toto,0 , sizeof(toto) ) ;
		flag = 0 ;ok = 0 ;total = 0 ;
		while( wish[j] != '\0' )
		{
			total ++ ;
			if( word[0] <='Z' && word[0] >='A' ) word[0] -= 'A'-'a' ;
			if ( strcmp( word , "beautiful") == 0 ||
				strcmp( word , "pretty" ) == 0 ||
				strcmp( word , "lovely" ) == 0 ) ok = 1 ;
			for( i = 1 ; i <= n ; i++ )
				if ( strcmp( word , name[i] ) == 0 )
				{
					if ( toto[i] == 0 ) flag++ ;
					toto[i]=1 ;
				}
			for( i = j ;i < strlen(wish) ; i++ )
			{
				if ( wish[i] != ' ' && wish[i] != '!' )
					word[i-j] = wish[i] ;
				else 
				{
					word[i-j] = '\0'  ;
					while(wish[i] == ' ' ||  wish[i] == '!' ) 
					i++ ;
					j = i ;
					break;
				}
			}
		}
		if ( flag!= 0 )
		{
		for( i = 1 ; i <= n ; i++ )
		{
			if ( toto[i] == 1 )
			{
				cout << name[i]  ;
				flag -- ;
				if ( flag != 0 ) cout << ' ' ;
	
			}
		}
		cout << ':' ;
		}
		else cout << "All:" ;
		if ( total <= 9 ) cout << " oh" <<endl;
		else if ( ok == 1 ) cout << " xixi" << endl;
		else cout << " hehe" << endl;
	}
}


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