View Code of Problem 50

#include <stdio.h>
#include <math.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    char str1[81], str2[81];
    int isNum;
    int i, j;
    
    gets(str1);
    for(i = 0, j = 0; i < strlen(str1); i++) {
        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] = '*';
    }
    for(i = 0; i < strlen(str2); i++) {
        printf("%c", str2[i]);
    }
    printf("\n");
}

Double click to view unformatted code.


Back to problem 50