View Code of Problem 50

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
 void main()
 {
	 int i,n,l,m,j=0,p;
	 char str1[80],str2[80];
	 gets(str1);
	 l=strlen(str1);
	
	 for(i=0;i<l;i++)
	 {

		 n=(int)str1[i];
		
         if(n>=48&&n<=57)
		 {
			
	          str2[j]=str1[i];
			  j++;	 
		 }
		 else if(n<48||n>57)
		 {
			  if(i<l-1)
			 { 
			 m=(int)str1[i+1];
			 if(m>=48&&m<=57)
			 {
			 str2[j]='*';
			 j++;
			 }
				 else
             str2[j]='*';

			  }
		 }
	 }
	p=(int)str1[l-1]; 
	if(p>57||p<48)
	 str2[j+1]='\0';
	else
     str2[j]='\0';
	 puts(str2);
	 
 }
	

Double click to view unformatted code.


Back to problem 50