sicily 1783. Large is Better

#include<iostream>
#include
<algorithm>
#include
<functional>
#include
<cstring>
using namespace std;
int main()
{
    
char ch[200];
    
int cases;
    cin
>>cases;
    
while(cases--)
    {
        cin
>>ch;
        
int s,t,len=strlen(ch);
        
for(s=0;s<len;++s)
            
if(ch[s]!='0')
                
break;
        
for(t=s;t<len;++t)
            
if(ch[t]=='0')
                
break;
        
while(s<len)
        {
            sort(ch
+s,ch+t,greater<char>());
            
for(s=t+1;s<len;++s)
                
if(ch[s]!='0')
                    
break;
            
for(t=s;t<len;++t)
                
if(ch[t]=='0')
                    
break;
        }
        cout
<<ch<<endl;
    }
    
return 0;
}

  

posted on 2011-07-14 16:48  sysu_mjc  阅读(210)  评论(0编辑  收藏  举报

导航