View Code of Problem 50

//
// Created by 大白MI on 2021/3/21.
//
#include <iostream>
#include <cstring>
using namespace std;
int  main(){
    string strInput;
    getline(cin,strInput);
    int len=strInput.length();
    string out="";
    int flag=0;
    for (int i = 0; i < len; ++i) {
        char ch=strInput.at(i);
        if (ch>='0'&&ch<='9'){
            if (flag==0){
                out+="*";
            }
            if (flag==0&&ch=='0'){

            } else{
                out+=ch;
            }
        
            flag=1;
        } else{
            flag=0;
        }
    }
    if (out.length()>0){
        out+="*";
    }
    cout<<out;
    return 0;
}

Double click to view unformatted code.


Back to problem 50