View Code of Problem 50

#include<stdio.h>
#include <string.h>
int main()
{
	char str[100];
	char strstr[100];
	gets(str);
	int n=strlen(str);
	int i;
	int m=0;
	if(str[0]>='0' && str[0]<='9')
		strstr[m++]=str[0];
	else
		strstr[m++]='*';
	for(i=1;i<n;i++)
	{
		if(str[i]>='0' && str[i]<='9')
		{
			strstr[m++]=str[i];
		}
		else
		{
			if(strstr[m-1]!='*')
			{
				strstr[m++]='*';
			}
		}
	}
	for(i=0;i<m;i++)
	{
		printf("%c",strstr[i]);
	}
	printf("\n");
	return 0;
}

Double click to view unformatted code.


Back to problem 50