题解 | #表示数字#

表示数字

http://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6

#include<iostream>
using namespace std;
int main()
{
    string str;
    while(cin>>str)
    {
        int i=0;
        string res;
        while(str[i]!='\0')
        {
            if(str[i]>='0'&&str[i]<='9')
            {
                res.push_back('*');
                while(str[i]!='\0'&&str[i]>='0'&&str[i]<='9')
                {
                    res.push_back(str[i]);
                    i++;
                }
                res.push_back('*');
            }
            else
            {
                res.push_back(str[i]);
                i++;
            }
        }
        cout<<res<<endl;
    }
    return 0;
}
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务