#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
/*
hdoj 1106
*/
using namespace std;
char a[1005];
long long b[1005]; //避免分割字符串的取值溢出
int main(){
char dem[]="5";
char *p;
while(gets(a)){
int i,x=0,sum;
p=strtok(a,dem);//获得第一次分隔符前的字符串
while(p){
sum = atoi(p); //将分割的字符串转化为整数数字 自动去掉前导0
b[x++]=sum; //将数字存到数组里去
p=strtok(NULL,dem); //继续分割 函数strtok()实际上修改了有str1指向的字符串。
//每次找到一个分隔符后,一个空(NULL)就被放到分隔符处,
//函数用这种方法来连续查找该字符串。
}
sort(b,b+x); //排序
for(i=0;i<x;i++){
printf(i!=x-1?"%d ":"%d",b[i]);//输出
}
printf("\n");
}
}
hdoj 1106
最新推荐文章于 2019-03-30 22:37:49 发布