View Code of Problem 50

#include<stdio.h>
#include<string.h>
int main()
{
	char a[81] = {0},b[81] = {0};
	int i,j = 0,n;
	gets(a);
	n = strlen(a);
	if (a[0] >= '0' && a[0] <= '9')
	{
		for (i = 0;i < n;i++)
		{
			if (a[i] >= '0' && a[i] <= '9')
			{
				if (j != 0)
				{
					b[j++] = '*';
				}
				while (a[i] >= '0' && a[i] <= '9')
				{
					b[j++] = a[i++];
				}
			}
		}
	}
	else
	{
		for (i = 0;i < n;i++)
		{
			if (a[i] >= '0' && a[i] <= '9')
			{
					b[j++] = '*';
				while (a[i] >= '0' && a[i] <= '9')
				{
					b[j++] = a[i++];
				}
			}
		}
	}
	if (a[n-1] < '0' || a[n-1] >'9') b[j] = '*';
	puts(b);
	return 0;
}

Double click to view unformatted code.


Back to problem 50