10098专题

UVa 10098: Generating Fast

这道题要求按字典序生成字符串的全排列,不可重复(但字符可以重复,且区分大小写)。 基本思路是先对输入的字符串按字典序排序,然后从第一位开始递归,从所有输入的字符中选出一个填充,然后再选第二位......具体实现看代码。 要注意的是最后的输出方式,不小心的话会莫名其妙的WA,详情见代码。 我的解题代码如下: #include <iostream>#include <cstdio>#i

UVA 10098

/*注意全排列中有重复的如 aac的全排列为aacacacaa*/ #include <stdio.h>#include <string.h>#include <stdlib.h>#define MAX 100int len, flag;char str[MAX];char num[MAX];int used[MAX];void dfs( int x ){int i;i