题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
#include <iostream> #include <string> using namespace std; int main() { string s; getline(cin, s); string ans; bool isnum = false; for (auto c : s) { if (isnum) { if (c >= '0' && c <= '9') { ans += c; } else { isnum = false; ans = ans + '*' + c; } } else { if (c >= '0' && c <= '9') { isnum = true; ans = ans + '*' + c; } else { ans = ans + c; } } } if (isnum) { ans += '*'; } cout << ans; } // 64 位输出请用 printf("%lld")