//MiYu原创, 转帖请注明 : 转载自 ______________白白の屋

题目地址 :
            http://acm.hdu.edu.cn/showproblem.php?pid=1106

很简单的一道水题, 就是直接字符串拆分就行了

代码: 
//MiYu原创, 转帖请注明 : 转载自 ______________白白の屋

#include <stdio.h>
#include 
<stdlib.h>
#include 
<string.h>
int cmp ( const void *p, const void *t )
{
    
return *(int *)p - *(int *)t;
}

char s[1010];
int a[1010];
int main()
{
    
while ( scanf("%s",s) != EOF )
    
{
          
char *t;
          
int n = 1;
          memset ( a, 
0sizeof ( a ) );
          t 
= strtok ( s,"5" );
          a[
0= atoi ( t );
          
while ( t = strtok ( NULL,"5" ) )
          
{
                 a[ n 
++ ] = atoi ( t );    
          }

          qsort ( a, n, 
sizeof ( int ), cmp );
          
for ( int i = 0; i != n; ++ i )
          
{  
                printf(i 
? " %d" : "%d",a[i]);
          }

          putchar ( 
'\n' );
    }

    
return 0;
}

 posted on 2010-08-18 15:08  MiYu  阅读(370)  评论(0编辑  收藏  举报