HDU ACM 3282 The Next Permutation->自打了解了STL,做题都省心多了
HDU ACM 3282 The Next Permutation->自从了解了STL,做题都省心多了
分析:这题也可以自己写,但是使用STL的函数next_permutation就非常方便了。
#include<iostream> #include<algorithm> #include<string> using namespace std; int main() { int t,n; char a[100]; cin>>t; while(t--) { cin>>n>>a; if(next_permutation(a,a+strlen(a))) cout<<n<<" "<<a<<endl; else cout<<n<<" BIGGEST"<<endl; } return 0; }