题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
#include <bits/stdc++.h> using namespace std; int main() { string str; getline(cin, str); for(int i=0; i<str.size(); i++){ if(i == 0 && (str[i]>='0' && str[i]<='9') && (str[i+1]<'0' || str[i+1]>'9')) cout << "*" << str[i] << "*"; else if(i == 0 && (str[i]>='0' && str[i]<='9') && (str[i+1]>='0' || str[i+1]<='9')) cout << "*" << str[i]; else if(i == str.size()-1 && (str[i]>='0' && str[i]<='9') && (str[i-1]<'0' || str[i-1]>'9')) cout << "*" << str[i] << "*"; else if(i == str.size()-1 && (str[i]>='0' && str[i]<='9') && (str[i-1]>='0' || str[i-1]<='9')) cout << str[i] << "*"; else if( (str[i]>='0' && str[i]<='9') && (str[i-1]<'0' || str[i-1]>'9') && (str[i+1]<'0' || str[i+1]>'9')) cout << "*" << str[i] << "*"; else if( (str[i]>='0' && str[i]<='9') && (str[i-1]<'0' || str[i-1]>'9') && (str[i+1]>='0' && str[i+1]<='9')) cout << "*" << str[i]; else if( (str[i]>='0' && str[i]<='9') && (str[i-1]>='0' || str[i-1]<='9') && (str[i+1]<'0' || str[i+1]>'9')) cout << str[i] << "*"; else cout << str[i]; } return 0; } // 64 位输出请用 printf("%lld")