给大家推荐个靠谱的公众号程序员探索之路,大家一起加油
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1106
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void *a,const void *b){
return *(int *)a-*(int *)b;
}
char s[1000];
int num[1000];
int main(){
char *p;
while(scanf("%s",s)!=EOF){
int n=1;
memset(num,0,sizeof(num[0]));//数组num全部赋值为0
p=strtok(s,"5");//分割字符串函数
num[0]=atoi(p);//将字符串转换为数字
while(p=strtok(NULL,"5")){//分割字符串函数
num[n++]=atoi(p);
}
qsort(num,n,sizeof(num[0]),cmp);
for(int i=0;i<n;i++){
if(i==(n-1)) printf("%d",num[i]);
else printf("%d ",num[i]);
}
printf("\n");
}
return 0;
}