标签:
<span style="font-size:18px;">#include <stdio.h>
#include <stdlib.h>//调用atoi函数时要用的头文件。
#include <string.h>
char s[1005];
int a[1005];
char * temp;
int cmp(const void *p1,const void *p2){
return *(int *)p1-*(int *)p2;
}
int main(){
int c;
while(gets(s)){
a[0]=atoi(strtok(s,"5"));//字符串切割函数strrok,atoi能将一个字符串转换成对应的float或者integer
c=1;
while(temp=strtok(NULL,"5")){
a[c++]=atoi(temp);
}
qsort(a,c,sizeof a[0],cmp);
for(int i=0;i<c;i++){
printf(i==c-1?"%d\n":"%d ",a[i]);
}
}
return 0;
}</span>版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/qjt19950610/article/details/47082445