| ||||||||||
| 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的时候遇到的坑第一个是大小写转换,只判断了大小写的元音,结果辅音忘记转换了,于是WA了一次,所以测试数据肯定有这样的:
HH
hh
hh
HH
prefect
第二个也是卡了时间较长的,不过如果不是我这个写法就没事,就是当输入是空格与输入是字母的时候处理是不一样的:空格的话,本次录入不能作为比较的字符串,字母的话,本次录入的是比较项,测试用例如下:
a yy
yy
yy
i yy
prefect
改了最后这个就过了,还是能力差劲。附C代码
#include<stdio.h>
#include<string.h>
int main()
{
char a[4][100];
int num , s , temp , t;
scanf("%d" , &num);
getchar();
for(s = 0 ; s < num ; s ++)
{
for(temp = 0 ; temp < 4 ; temp ++)
{
for(t = 0 ; 1 ; t ++)
{
a[temp][t] = getchar();
if(a[temp][t] == '\n')
{
a[temp][t] = '\0';
break;
}
if(a[temp][t] >= 'a' && a[temp][t] <= 'z')
{
a[temp][t] = (char)(a[temp][t] - 32);
}
if(a[temp][t] == 'A' || a[temp][t] == 'E' || a[temp][t] == 'I' || a[temp][t] == 'O' || a[temp][t] == 'U')
{
a[temp][0] = a[temp][t];
t = 0;
}
else if(a[temp][t] == ' ')
{
t = -1;
}
}
}
if(strcmp(a[0] , a[1]) == 0)
{
if(strcmp(a[2] , a[3]) == 0)
{
if(strcmp(a[1] , a[2]) == 0)
{
printf("perfect\n");
continue;
}
else
{
printf("even\n");
continue;
}
}
printf("free\n");
}
else if(strcmp(a[0] , a[2]) == 0)
{
if(strcmp(a[1] , a[3]) == 0)
{
printf("cross\n");
continue;
}
printf("free\n");
}
else if(strcmp(a[0] , a[3]) == 0)
{
if(strcmp(a[1] , a[2]) == 0)
{
printf("shell\n");
continue;
}
printf("free\n");
}
else
printf("free\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