| ||||||||||
| 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 | |||||||||
各位路过的高手给我看看我的代码,我已经WA好几次了!/第一个
#include<stdio.h>
#include<string.h>
#define V 555
int main()
{
char girl[V][V],word[V],str_num[V];
int g,w;
while(~scanf("%d %d",&g,&w))
{
int sum=0;
char str[V];
for(int i=0;i<g;i++)
scanf("%s",&girl[i]);
for(int i=0;i<w;i++){
getchar();
gets(word);
int s=0;
int q=0;
int e=0;
memset(str,0,sizeof(str));
int b=0;
for(int j=0,k=0;j<strlen(word);j++)
{
if(word[j]>='A'&&word[j]<='Z')
word[j]=word[j]+32;
if(word[j]==' '||word[j]=='!'){
for(int p=0;p<g;p++){
if(strcmp(str,girl[p])==0){
for(int a=0;a<strlen(girl[p]);a++,b++)
str_num[b]=girl[p][a];
str_num[b]=' ';
b++;
q++;
}
if(strcmp(str,"beautiful")==0||strcmp(str,"pretty")==0||strcmp(str,"lovely")==0)
e++;
}
k=0;
s++;
memset(str,0,sizeof(str));
}
else{
str[k]=word[j];
k++;
}
}
if(!q) {
if(s<=9) printf("All: oh\n");
else{
if (s>=10&&!e) printf("All: hehe\n");
else printf("All: xixi\n");
}
}
else
{
for(int j=0;j<b-1;j++) printf("%c",str_num[j]);
if(s<=9) printf(": oh\n");
else{
if (s>=10&&!e) printf(": hehe\n");
else printf(": xixi\n");
}
}
}
}
}
/第二个
#include<stdio.h>
#include<string.h>
#define V 555
int main()
{
char girl[V][V],word[V],str_num[V];
int g,w;
while(~scanf("%d %d",&g,&w))
{
int sum=0;
char str[V];
int mark[V];
for(int i=0;i<g;i++)
scanf("%s",&girl[i]);
for(int i=0;i<w;i++){
getchar();
gets(word);
memset(mark,0,sizeof(mark));
int s=0;
int q=0;
int e=0;
memset(str,0,sizeof(str));
for(int j=0,k=0;j<strlen(word);j++)
{
if(word[j]>='A'&&word[j]<='Z')
word[j]=word[j]+32;
if(word[j]==' '||word[j]=='!'){
for(int p=0;p<g;p++){
if(strcmp(str,girl[p])==0){
mark[p]=1;
q++;
}
if(strcmp(str,"beautiful")==0||strcmp(str,"pretty")==0||strcmp(str,"lovely")==0)
e++;
}
k=0;
s++;
memset(str,0,sizeof(str));
}
else{
str[k]=word[j];
k++;
}
}
if(!q) {
if(s<=9) printf("All: oh\n");
else{
if (s>=10&&!e) printf("All: hehe\n");
else printf("All: xixi\n");
}
}
else
{
int a=0;
for(int j=0;j<g;j++)
if(mark[j]){
for(int k=0;k<strlen(girl[j]);k++){
str_num[a]=girl[j][k];
a++;
}
str_num[a]=' ';
a++;
}
for(int j=0;j<strlen(str_num)-1;j++)
printf("%c",str_num[j]);
if(s<=9) printf(": oh\n");
else{
if (s>=10&&!e) printf(": hehe\n");
else printf(": xixi\n");
}
getchar();
}
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator