| ||||||||||
| 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 | |||||||||
我的程序读入单词没问题,为什么还是不过?#include<iostream>
#include<cstring>
using namespace std;
char dic[10][40]={"beautiful","pretty","lovely"};
int flag[10];
int g;
void cmp(char *p)
{
for(int i = 0;i < g && strcmp(p,dic[i]);i ++);
flag[i] = 1;
}
int main()
{
int w,n,i,ncmp;//w,wish;n ,number of word;
char word[200],l; //i,word[i];ncmp ,no. of comp;
cin >> g >> w;g += 3;
for(i = 3;i < g;i ++)
{
cin >> word;
strcpy(dic[i],word);
}
while(w --)
{
n = 0;ncmp = 0;
for(i = 0; i< 50;i ++)
word[i] = 0;
for(i = 0;i < 10;i ++)
flag[i] = 0;
i = 0;
l = getchar();
while(l == '\n')
l = getchar();
while(l != '\n')
{
if(l == ' ' || l == '!')
{
if(!ncmp)
{
n ++;cmp(word);ncmp = 1;
for(i = 0;i < 50;i ++)
word[i] = 0;
i = 0;
}
}
else
{
ncmp = 0;
if(l <= 'Z')
l += 'a'- 'A';
word[i++] = l;
}
l = getchar();
}
for(i = 3,ncmp = 0;i < g;i ++)
if(flag[i])
{
if(ncmp)
cout << ' ' ;
cout << dic[i];
ncmp += 1;
}
if(!ncmp)
cout << "All";
cout << ": ";
if(n <= 9)
cout << "oh\n";
else
if(flag[0] + flag[1] + flag[2])
cout << "xixi\n";
else
cout << "hehe\n";
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator