View Code of Problem 50

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

Double click to view unformatted code.


Back to problem 50