View Code of Problem 50

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
    char str1[1000],str2[1000];
    gets(str1);
    int i,j;
    for(i=0,j=0; i<strlen(str1); i++)
    {
        if(str1[i]>='0' && str1[i]<='9')
        {
            str2[j++]=str1[i];
        }
        else
        {
            str2[j++]='*';
        }
    }
    for(i=0; i<j; i++)
    {
        if(str2[i]=='*')
        {
            if(str2[i+1]=='*')
            {
                continue;
            }
            else
            {
                printf("*");
            }
        }
        else
        {
            printf("%c",str2[i]);
        }
    }

}

Double click to view unformatted code.


Back to problem 50