View Code
1 //保留整数 2 #include<stdio.h> 3 #include<string.h> 4 int main() 5 { 6 char s1[100],s2[100]; 7 int i,j,k,c; 8 gets(s1); 9 c=0;k=0;j=0; 10 for(i=0;s1[i]!='\0';i++) 11 { 12 if(s1[i]>='0'&&s1[i]<='9') 13 { 14 s2[k++]=s1[i]; 15 c=0; 16 } 17 if((s1[i]<'0'||s1[i]>'9')&&(c==0)) 18 { 19 s2[k++]='*'; 20 c=1; 21 } 22 } 23 s2[k]='\0'; 24 printf("%s\n",s2); 25 return 0; 26 } 27 /*123414jjafjfjf999 28 123414*999*/ 29