next_permutation是个好东西
#include<bits/stdc++.h>
using namespace std;
int t,n,c;
int main()
{
    cin>>t;
    string str;
    for(c=0;c<t;c++)
    {
        cin>>str;
        if(is_sorted(str.begin(),str.end(),greater<char>()))str="0"+str;
        next_permutation(str.begin(),str.end());
        printf("case #%d:\n%s\n",c,str.c_str());
    }
}
 
         
         
         
        
md辛辛苦苦写了之后,发现这个函数,不是作弊吗
STL里居然还有这种函数。。感谢分享