View Code of Problem 50

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

int main()
{
	char str1[82],str2[82];
	int length, i, count = 0,flag = 0;
	gets(str1);
	length = strlen(str1);
	
	for(i = 0; i < length;i++)
	{
		if(str1[i] >= '0' && str1[i] <= '9')
		{
			if(flag)
				str2[count++] = '*';
			str2[count++] = str1[i];
			flag = 0;
		}
		else
			flag = 1; 
	}
	if(str1[length - 1] < '0' || str1[length - 1] > '9')
		str2[count++] = '*';
	str2[count] = '\0';
	printf("%s", str2);
	
	return 0;
}

Double click to view unformatted code.


Back to problem 50