题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
// HJ96-2 表示数字.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
while (cin >> s)
{
for (int i = 0; i < s.size(); i++)
{
if (isdigit(s[i]))
{
s.insert(i, "*");
int j = i+1;
while (isdigit(s[j]))
{
j++;
}
s.insert(j, "*");
i = j ;
}
}
cout << s << endl;
}
return 0;
}

查看11道真题和解析