题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
#include <stdio.h> #include <string.h> int main() { char str[101] = { 0 }; scanf("%s", str); int len = strlen(str); char res[201] = { 0 }; int pos = 0; for (int i = 0; i < len; i++) { if (str[i] >= '0' && str[i] <= '9') { int c = 1; char arr[101] = { 0 }; arr[0] = '*'; while (str[i] >= '0' && str[i] <= '9') { arr[c++] = str[i]; i++; } arr[c] = '*'; strncpy(res + pos, arr, c + 1); pos = pos + c+1; } res[pos++] = str[i]; } printf("%s\n", res); return 0; }