题目地址 :
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, 0, sizeof ( 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;
}
#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, 0, sizeof ( 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;
}