Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/u011544909/article/details/79947755
Title describes
a character that appears in all the numbers before and after the plus symbol "*", other characters remain constant
public static String MarkNum (String pInStr)
{
null return;
}
Input Description:
enter a string
Output Description: The
character that appears in all the numbers before and after the plus symbol "*", other characters remain unchanged
Example 1
Input
Jkdi234klowe90a3
output
Jkdi * 234 * klowe * 90 * a * 3 *
We can start with the unification of the two numbers * parcel number, and then appear in the case of ** remove the string.
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main()
{
string str;
while(cin>>str)
{
string temp="";
for(int i=0;i<str.size();i++)
{
if(isdigit(str[i])){
temp+='*';
temp+=str[i];
temp+='*';
}
else
temp+=str[i];
}
while(temp.find("**")!=string::npos)
{
auto pos =temp.find("**");
if(pos!=string::npos)
temp=temp.substr(0,pos)+temp.substr(pos+2);
}
cout<<temp<<endl;
}
return 0;
}