0051231232050775
0 77 12312320
睡前一水
代码:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define M 1005
using std::sort;
int s[M];
char str[M];
int main(){
while(gets(str)){
int len, tot = 0, i;
len = strlen(str);
i = 0;
//while(str[i] == '0') i++;
while(str[i] == '5') i++;
int temp = 0;
while(i < len){
if(str[i] == '5'){
i++;
while(i<len&&str[i] == '5') i++;
s[tot++] = temp; temp = 0;
}
else{
temp = temp*10+str[i]-'0'; i++;
}
}
if(str[len-1] != '5') s[tot++] = temp;
sort(s, s+tot);
printf("%d", s[0]);
for(i = 1; i < tot; i ++) printf(" %d", s[i]);
printf("\n");
}
return 0;
}原文:http://blog.csdn.net/shengweisong/article/details/41056775