| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:为什么还是WA啊?(附程序)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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator