C语言程序设计——字符串

2025-07-03 11:42:27
推荐回答(1个)
回答1:

void fun(char *str)
{
int i=0,j=0;
char s1[80],s2[80];
char *p=str;
while(*p)
{
if(isdigit(*p))
s1[i++]=*(p++);
else s2[j++]=*(p++);
}
s1[i]=s2[j]='\0';
strcpy(str,s2);
strcat(str,s1);
}
其实,用链表是最好的,不过题目既然已经给出了用字符串数组,那就只好多用点内存,提高点速度了。
#include "ctype.h"
#include "string.h"