View Code of Problem 50

#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
 
int main()
{
    char str1[80];
    char str2[80];
    gets(str1);
 
    int j=0;
    int flag = 1;
    for(int i=0;str1[i] != '\0';i++){
        if(str1[i]>='0' && str1[i]<='9'){
            str2[j++] = str1[i];
            flag = 1;
        }
        else{
            if(flag == 1){
                str2[j++] = '*';
                flag = 0;
            }
        }
    }
    str2[j] ='\0';
 
    for(int i=0;str2[i] != '\0';i++){
        cout<<str2[i];
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 50