文章

7

粉丝

309

获赞

5

访问

64.1k

头像
字符串移动函数
P1012 贵州大学机试题
发布于2020年2月3日 20:25
阅读数 8.9k

#include<stdio.h>
#include<string.h>
char* move_string(char* s){
int n=strlen(s);
int id_num=0;
int id_oth=0;
char num_s[100]={100};
char oth_s[100]={100};
for(int i=0;i<=n-1;i++){
    if(s[i]>='0'&&s[i]<='9')
        num_s[id_num++]=s[i];
    else oth_s[id_oth++]=s[i];
}
for(int i=0;i<=id_num-1;i++){
    oth_s[id_oth++]=num_s[i];
}
oth_s[id_oth]='\0';
//printf("%s",oth_s);
char* s_re=oth_s;
//printf("%s\n",s_re);
return s_re;
}

int main(){
char s[100]={0};
scanf("%s",s);
char* s1=move_string(s);
printf("%s",s1);
return 0;
}
 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发