1 #include<stdio.h> 2 int main() 3 { 4 char str[100],temp[100],*ch,*p; 5 ch=p=str; 6 int i=0,j=0; 7 gets(str); 8 while(*p++) //将字母抓取到另一个数组中 9 if(*p>=‘a‘&&*p<=‘z‘||*p>=‘A‘&&*p<=‘Z‘) 10 temp[i++]=*p; 11 i--; //由于最后一次自增没有值所以将下标回退一个 12 for(;str[j]!=‘\0‘;j++) //将数组中的0-9部分抓取从数组头部开始覆盖 13 if(str[j]>=‘0‘&&str[j]<=‘9‘) 14 *ch++=str[j]; 15 while(i>=0) //覆盖完接着将字母接着数字部分继续覆盖 16 *ch++=temp[i--]; 17 puts(str); 18 19 return 0; 20 }
原文:https://www.cnblogs.com/old-horse/p/14643459.html