2279: 字符串分段(串)
Description 输入一个字符串,将其分段输出,分段符为除字母和数字之外的符号。 Input 输入一个字符串 Output 输出分段后的字符串 Sample Input** ad/adfa,,123d?#a1 Sample Output ad adfa 123d a1
参考解答:
#include <stdio.h>
int main( )
{
char s[
20];
int i=
0,c=
1;
gets(s);
while(s[i]!=
'\0')
{
if((s[i]>=
'A'&&s[i]<=
'Z')||(s[i]>=
'a'&&s[i]<=
'z')||(s[i]>=
'0'&&s[i]<=
'9'))
{
printf(
"%c",s[i]);
c=
1;
}
else if(c==
1)
{
printf(
"\n");
c=
0;
}
i++;
}
return 0;
}
相关资源:python入门教程(PDF版)