UVA 146 ID Codes(排列)

来源:互联网 发布:数据恢复软件合集 编辑:程序博客网 时间:2024/05/16 12:03
题意:给你一个字符串,求它的下一个排列,按字典序。

思路:水题,用到一下next_permutation 求下一个排列函数。


//0 KB18 ms#include <stdio.h>#include <string.h>#include <algorithm>#define M 55using namespace std;int main (){    char str[M];    while (~scanf ("%s",str))    {        if (str[0] == '#')            break;        int len = strlen(str);        if (next_permutation(str,str+len))            printf ("%s\n",str);        else            printf ("No Successor\n");    }    return 0;}


原创粉丝点击