题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
#include <iostream> using namespace std; #include <string> #include <cctype> int main() { string str; getline(cin, str); for (int i = 0; i < str.size() ;i++) { if(isdigit(str[i])){ cout << "*"; cout << str[i]; i++; while(isdigit(str[i])){ cout << str[i]; i++; } cout << "*"; if(i<str.size()){ cout <<str[i]; } } else{ cout << str[i]; } } }
遇到数字就进行特殊输出即可