题解 | #表示数字#
表示数字
http://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
#include<stdio.h>
#include<string.h>
int main()
{
char a[100];
int i = 0, j = 0;
int x;
char ch;
while(scanf("%s",a) == 1){
while(i<=strlen(a)){
if(a[i] >= '0' && a[i] <= '9'){
if(a[i-1] <'0' || a[i-1] > '9'){
for(j = strlen(a);j>=i;j--){
a[j+1] = a[j];
}
a[i] = '*';
i++;
}
else if(i == strlen(a) )
a[i+1] = '*';
}else {
if(a[i-1] >='0' && a[i-1] <= '9'){
for(j = strlen(a) ;j>=i;j--){
a[j+1] = a[j];
}
a[i] = '*';
i++;
}
}
i++;
}
printf("%s\n",a);
x = strlen(a);
for(i = 0;i<x ; i++){
a[i] = '\0';
}
i = 0;
}
return 0;
}
#include<string.h>
int main()
{
char a[100];
int i = 0, j = 0;
int x;
char ch;
while(scanf("%s",a) == 1){
while(i<=strlen(a)){
if(a[i] >= '0' && a[i] <= '9'){
if(a[i-1] <'0' || a[i-1] > '9'){
for(j = strlen(a);j>=i;j--){
a[j+1] = a[j];
}
a[i] = '*';
i++;
}
else if(i == strlen(a) )
a[i+1] = '*';
}else {
if(a[i-1] >='0' && a[i-1] <= '9'){
for(j = strlen(a) ;j>=i;j--){
a[j+1] = a[j];
}
a[i] = '*';
i++;
}
}
i++;
}
printf("%s\n",a);
x = strlen(a);
for(i = 0;i<x ; i++){
a[i] = '\0';
}
i = 0;
}
return 0;
}