uva146-ID码

此题为小白书暴力求解法的训练参考

 

翻译请戳 http://luckycat.kshs.kh.edu.tw/

 

解题思路

嗯。。。用c++里的next_permutation。。。

 

代码

#include<cstdio>
#include<algorithm>
#include<string.h> 
const int maxLen = 55;
char s[maxLen];
using namespace std;
int main()
{
    scanf("%s", s);
    while(strchr(s, '#') == NULL) {
        char copy[maxLen];
        strcpy(copy, s);
        if(next_permutation(copy, copy+strlen(copy))) printf("%s\n", copy);
        else printf("No Successor\n");
        scanf("%s", s);
    }
    return 0;
}

 

posted @ 2016-08-11 23:20  啊嘞  阅读(146)  评论(0)    收藏  举报