View Code of Problem 50

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

int main() {
    string s;
    getline(cin,s);
    bool flag = true;
    string str = "";
    for(int i=0; i<s.size(); i++){
        if(s[i] <='9' && s[i] >= '0'){
            flag = true;
            str += s[i];
            continue;
        }
        if(flag){
            str += "*";
            flag = false;
        }
    }
    cout << str;
    return 0;
}

Double click to view unformatted code.


Back to problem 50