Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
26822 唐心 分割排序 C++ Accepted 2 MS 728 KB 668 2022-05-24 17:05:00

Tests(1/1):


Code:

#include <iostream> #include <cstdlib> #include <cstring> #include <cmath> #include<algorithm> using namespace std; int main() { int i,j,n,num,cnum=0; char str[1001]; int arr[100]; while(cin >> str) { num = strlen(str); cnum = 0; j = 0; n = 0; while(str[j]=='5') j++; for(i = j; i < num ;i++) { if(str[i]!='5') { cnum = cnum*10+(str[i]-'0'); } else if(str[i] == '5' && str[i-1]!='5') { arr[n++] = cnum; cnum = 0; } } if(str[num-1] != '5') arr[n++] = cnum; sort(arr,arr+n); cout<<arr[0]; for(i=1;i<n;i++) cout<<" "<<arr[i]; cout <<endl; } return 0; }