题解 | #表示数字#还是用到了push——back 我的好兄弟
表示数字
http://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int n=0,m=0;
string str;
char c;
while(cin>>c)
{
if(c>='0'&&c<='9'&&n == 0&&m==0)
{
str.push_back('*');
str.push_back(c);
n = 1;
m = 1;
}
else if(c>='0'&&c<='9'&&n == 0&&m==1)
{
str.push_back(c);
str.push_back('*');
n = 1;
m = 1;
}
else if(c>='0'&&c<='9'&&n == 1)
{
str.push_back(c);
}
else{
if(n==1)
str.push_back('*');
str.push_back(c);
n=0;
m=0;
}
}
if(str[str.size()-1] >='0'&&str[str.size()-1] <='9')
{
str.push_back('*');
}
cout<<str;
}