以5为界,分开后,排序输出。。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
bool cmp ( int a, int b ) {
return a < b;
}
int main ( ) {
int i, count, num[1005];
char s[1005], *p;
while ( scanf ( "%s", s ) != EOF ) {
count = 0;
p = strtok ( s, "5" );
printf ( "%s\n", p );
while ( p != NULL ) {
num[count++] = atoi ( p );
p = strtok ( NULL, "5" );
}
sort ( num, num + count, cmp );
printf ( "%d", num[0]);
for ( i = 1; i < count; ++i )
printf ( " %d", num[i] );
printf ( "\n" );
}
}