题目
代码
//StudybarCommentBegin
#include <stdio.h>
#include <string.h>
int main()
{
void GetOthers(char s[]);
char str[100];
gets(str);
GetOthers(str);
printf("%s",str);
return 0;
}
//StudybarCommentEnd
void GetOthers(char s[])
{
int i=0;
int j=0;
for(i=0;s[i]!='\0';i++)
{
if((s[i]>='A'&&s[i]<='Z')||(s[i]>='a'&&s[i]<='z'))//或者在前面加!
;
else
{
s[j]=s[i];
j++;
}
}
s[j]='\0';
}
tips
函数中的if判断可改为:(在判断语句前加!表示取反)
if(!(s[i]>='A'&&s[i]<='Z')&&!(s[i]>='a'&&s[i]<='z'))
{
s[j]=s[i];
j++;
}