阅读388 返回首页    go 微软 go windows


POJ1146

这题就是求字典序的下一个排列 用STL里的next_permutation函数就能轻松解决 

处理过这种问题 在加上sort函数 很巧妙的解决了问题

#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
    char yl[55],as[55];
    while(~scanf("%s",yl)&&strcmp(yl,"#")!=0)
    {
        int len=strlen(yl),n=0;
        strcpy(as,yl);
        sort(as,as+len);
        next_permutation(yl,yl+len);
        if(strcmp(yl,as)==0)
            cout<<"No Successor"<<endl;
        else
            cout<<yl<<endl;
    }
    return 0;
}


最后更新:2017-04-04 07:03:32

  上一篇:go BookService数组调用
  下一篇:go ActivityGroup中出现的Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@