现在的位置: 首页 > 综合 > 正文

UVa146 ID Codes (排列)

2018年12月20日 ⁄ 综合 ⁄ 共 257字 ⁄ 字号 评论关闭

生成下一个排列, 用 next_permutation 。

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

int main()
{
    char s[60];
    int i, n;
    while(scanf("%s",s))
    {
        if(s[0]=='#')break;
        n = strlen(s);
        if( next_permutation(s,s+n) )
            printf("%s\n",s);
        else
            printf("No Successor\n");
    }
    return 0;
}

抱歉!评论已关闭.