1 solutions

  • 0
    @ 2024-12-10 23:39:22

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    const int maxn=1e3+10;
    char str[maxn];
    int a[maxn],t;
    int main()
    {
    	while(scanf("%s",str)!=EOF)
    	{
    		memset(a,0,sizeof(a));
    		int len=strlen(str);str[len]='5';t=0;
    		for(int i=0;i<=len;i++)
    		{		
    			while(str[i]=='5')i++;
    			while(str[i] != '5')a[t]=a[t]*10+str[i]-'0',i++;
    			t++;
    		}
    		if(str[len-1]=='5')t--;
    		sort(a+0,a+t);
    		for(int i=0;i<t-1;i++)cout<<a[i]<<" ";
    		cout<<a[t-1]<<"\n";
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    617
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    # Submissions
    17
    Accepted
    1
    Uploaded By