参考:https://blog.csdn.net/dxx_111/article/details/48154687
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstring> 5 const int N=1e3+5; 6 char a[N]; 7 int b[N]; 8 using namespace std; 9 int main() 10 { 11 // freopen("E:\\ACM\\text.txt","r",stdin);//提交前记得注释此句~ 12 while (scanf("%s",a)!=EOF) 13 { 14 memset(b,0,sizeof(b)); 15 int t=0,c=0,len=strlen(a); 16 for (int i=0;i<len;i++) 17 { 18 if (a[i]!='5') 19 { 20 t=t*10+a[i]-'0'; 21 } 22 if ((a[i]!='5'&&a[i+1]=='5')||(a[i]!='5'&&a[i+1]=='\0'))//在&&子句加上括号,以防warning~注意开头为5的情况~ 23 { 24 b[c++]=t; 25 t=0; 26 } 27 } 28 sort(b,b+c); 29 printf("%d",b[0]); 30 for (int i=1;i<c;i++)//没有说要去重,所以不能用set~ 31 { 32 printf(" %d",b[i]); 33 } 34 printf("\n"); 35 } 36 37 return 0; 38 }