View Code of Problem 50

#include<stdio.h>
#include<string.h>
#include<math.h>
void main(){
	char str1[80],str2[80];
	int l,i,j=0,k;
	gets(str1);
	l=strlen(str1);
	if(str1[0]>=48&&str1[0]<=57){
		str2[j]=str1[0];
		j++;
	}
	for(i=1;i<l;i++){
		if(str1[i]>=48&&str1[i]<=57){
			if(str1[i-1]<48||str1[i-1]>57){
				str2[j]='*';
				j++;
				str2[j]=str1[i];
				j++;
			}
			else{
				str2[j]=str1[i];
				j++;
			}
			k=i;
		}		
	}
	if(k+1<l)
		str2[j++]='*';
	str2[j]='\0';
	puts(str2);
}

Double click to view unformatted code.


Back to problem 50