View Code of Problem 50

#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
	char str1[80],str2[80];
	int i,j = 0;
	getchar();
	gets(str1);
	for(i = 0;i < strlen(str1);i++)
	{
		if(str1[i] >= '0'&&str1[i] <= '9')
			str2[j++] = str1[i];
		if(str1[i] <= '0'||str1[i] >= '9')
			if(isdigit(str1[i+1]))
				str2[j++] = '*';
	}
	if(str1[i-1] <= '0'||str1[i-1] >= '9')
	{
		str2[j] = '*';
		str2[j+1] = '\0';
	}
	else
		str2[j] = '\0';
	printf("%s",str2);
	return 0;
}

Double click to view unformatted code.


Back to problem 50