忽略字母大小写,下面是我当时写的代码,求各位大婶指教怎么改进不会让人觉得缺经验,或者贴下你的代码,感谢
{
if((s1==null)||(s2==null))
exit(1);
int c='a'-'A',i=0;
char *temps1=s1,*temps2=s2;
while(*temps1!='\0')
{
int i1=0;
while((*temps1==*temps2)||({*temps1+c)==*temps2)||(*temps1==(*temps2+c)))
{
temps1++;
temps2++;
if('\0'==*temps2)
return (s1+i-i1);
i++;
i1++;
}
temps2=s2;
temps1++;
i++;
}
return null;
}
贴题目出来啊,要不怎么能看出要考什么
为什么是两个While循环,一个就搞定了。
**{
if(s1&&s2)
return 0;
int i=0;
char *temps1=s1,*temps2=s2;
while(*temps2!='\0'&&*temps1!='\0')
{
if(*temps1==*temps2||(*temps1-*temps2)=='(a'-'A')||(*temps1-*temps2)==('A'-'a'))
{temps1++;temps2++;i++;}
else if(temps2!=s2&&*temps2!='\0'){temps2=s2;i=0;}
}
if(temps2=='\0'&&temps1!=s1)
return temps1-i;
else return 0;
}**