http://acm.hdu.edu.cn/showproblem.php?pid=1106&&排序

尼玛坑爹的水题,得注意细节,,,,

#include<iostream>
#include<string.h>
#include<string>
#include<set>
using namespace std;
int main()
{
	string s;
	while(cin>>s)
	{
		multiset<int>Q;
		int n=s.size();
		int i=0;
		string s1="\0";
		while(i<n)
		{
		   if(s[i]!='5') s1+=s[i];
		  else if(s1.size()>0&&s[i]=='5')//当s1不为空时才处理
			{
				
				int b=atoi(s1.data());
				Q.insert(b);
		        s1="\0";
			}
		   i++;
		}
		if(s1.size()>0) 
			{
				int b=atoi(s1.data());
				Q.insert(b);
			}
	multiset<int>::iterator it;
		cout<<*(Q.begin());
		for(it=++Q.begin();it!=Q.end();++it)
			cout<<" "<<*it;
		    cout<<endl;
	}return 0;
}


你可能感兴趣的:(http://acm.hdu.edu.cn/showproblem.php?pid=1106&&排序)