Problem Description
输入一个字符串str1,把其中的连续非数字的字符子串换成一个‘*’,存入字符数组str2 中,所有数字字符也必须依次存入 str2 中。输出str2。
Input
输入为一行字符串str1,其中可能包含空格。字符串长度不超过80个字符。
Output
输出处理好的字符串str2。
Example Input
$Ts!47&*s456 a23* +B9k
Example Output
*47*456*23*9*
Hint
Author
代码:
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char st1[85],st2[85]; int i,k,n; i=n=0; gets(st1); k=strlen(st1); while(i<k) { while(st1[i]>='0'&&st1[i]<='9') { st2[n]=st1[i]; i++; n++; } if(i<k) { while(st1[i]<'0'||st1[i]>'9')i++; st2[n]='*'; n++; } } for(i=0; i<n; i++) printf("%c",st2[i]);
printf("\n"); return 0; }