// // 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+="*"; } out+=ch; flag=1; } else{ flag=0; } } if (out.length()>0){ out+="*"; } cout<<out<<endl; return 0; } |
Double click to view unformatted code.