#include <stdio.h> #include <math.h> #include <string.h> int main(int argc, const char * argv[]) { char str1[81], str2[81]; int i, j; gets(str1); for(i = 0, j = 0; i < strlen(str1); i++) { int isNum = str1[i] >= '0' && str1[i] <= '9'; if(isNum) { str2[j++] = str1[i]; } else if(!isNum && str1[i + 1] >= '0' && str1[i + 1] <= '9') { str2[j++] = '*'; } } if(!(str1[i - 1] >= '0' && str1[i - 1] <= '9')) { str2[j++] = '*'; } str2[j] = '\0'; puts(str2); } |
Double click to view unformatted code.