如”h1ell2o3“-->“123hello”
之前在csdn上查了一下别人写的,啥玩意啊,开辟个啷个大的数组往里塞,这谁tm不会写啊,
于是老老实实自己写了个尽可能不开辟空间(除去工作指针/计数器 声明)的算法
请无视单词错误,word懒得改了,洋文没学好
void world_sort(char* str) {
int num_count = 0;
char* p = str;
char* p_num = NULL;
char* p_world = NULL;
if (*str < '0' || *str >'9') {
p_world = str;
}
else {
p_num = str;
num_count++;
}
while (*str) {
if (*str < '9' && *str >'0') {
p_num = str;
num_count++;
}
else if((*(str - 1) > '0' && *(str-1) <'9') && (* str <'0' || *str >'9') ) {//前一个字符是数字,当前字符是字母,即,找到第一个字母
p_world = str;
}
if (p_num != NULL && p_world != NULL) {
while (p_world < p_num) {
char temp = *p_num;
*p_num = *(p_num -