View Code of Problem 50

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){
  char str1[100];
  char str2[100];
  scanf("%[^\n]",str1);
  int j=0;
  for(int i =0;i<strlen(str1);i++)
  {
    if(str1[i] >= '0' && str1[i] <= '9')
        str2[j++] = str1[i];
    else
    {
        if(i+1 == strlen(str1))
            str2[j++] = '*';
        if(str1[i+1] >= '0' && str1[i+1] <= '9')
            str2[j++] = '*';
        else
            continue;
    }
  }
  printf("%s\n",str2);
  return 0;
}

Double click to view unformatted code.


Back to problem 50