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

POJ 1146 ID Codes

2019年04月09日 ⁄ 综合 ⁄ 共 404字 ⁄ 字号 评论关闭

next_permutation解之。

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

const int MAXN = 60;

char str[MAXN];

void solve()
{
	int len = strlen(str);
	bool f = next_permutation(str, str+len);
	if(!f)
	{
		printf("No Successor\n");
	}
	else printf("%s\n", str);
}

bool read_case()
{
	scanf("%s", str);
	if(str[0] == '#') return 0;
	return 1;
}

int main()
{
	while(read_case())
	{
		solve();
	}
	return 0;
}

抱歉!评论已关闭.