#include #include using namespace std;char chars[] = {'a', 'b', 'c'};char result[3];int flag[3] ; // 用于标记是否使用过int len;// 注意,为了打印,这个函数需要接受一个结果数组,来记录每次递...
分类:
其他好文 时间:
2014-10-11 15:30:05
阅读次数:
145
package oj.lin;public class quanpailie { public static void main(String[] args) { char buf[]={'a','b','c'}; perm(buf,0,buf.length-1...
分类:
其他好文 时间:
2014-10-10 14:19:14
阅读次数:
203
深搜注意与STL模版的去重函数唯一的区别就是有去重。#include #include #include #include using namespace std;int len;char ch[15],ss[15];int visted[15];bool cmp(char a,char b){ ....
分类:
其他好文 时间:
2014-10-09 23:18:27
阅读次数:
202
// 全排列问题.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include
using namespace std;
template
void swap(T *str1,T *str2)
{
T temp;
temp=*str1;
*str1=*str2;
*str2=temp;
}
void permStr(char *str,...
分类:
其他好文 时间:
2014-10-09 16:32:48
阅读次数:
187
以数字举例:有一个数组A的数为 :1 2 3 4 ,其按字典序列的全排列为: 1 2 3 4 1 3 2 4 1 3 4 2 1 4 2 3 1 4 3 2 2 1 3 4 2 1 4 3 2 3 4 1 .......... 总共有 n!个排列,现在输入一个数K,输出其第K的排列 方法...
分类:
其他好文 时间:
2014-10-08 00:23:44
阅读次数:
292
用C++模板书写一段序列数组的全部排列
/**
* 书本:【windows程序设计】
* 功能:输出全部的排列情况
* 文件:全排列.cpp
* 时间:2014年9月29日21:52:55
* 作者:cutter_point
*/
#include
using namespace std;
//交换两个元素的函数
template
inline void Swap(Type &a...
分类:
其他好文 时间:
2014-09-30 00:33:47
阅读次数:
344
var Ann = function a(arr){if(arr.length == 1){return arr;}var rr = new Array();for(var i = 0; i<arr.length;i++){//get a copyvar ar = new Array();for(v...
分类:
编程语言 时间:
2014-09-29 14:15:11
阅读次数:
206
DescriptionDr lee cuts a string S into N pieces,s[1],…,s[N]. Now, Dr lee gives you these N sub-strings: s[1],…s[N]. There might be several possibiliti...
分类:
其他好文 时间:
2014-09-28 21:56:35
阅读次数:
243
说说:
这题的意思就是给你一个01串的总长度和其中1的个数,要你求出该串的所有排列,并按照字典升序输出。其实这道题和前一道Generating Fast是非常类似的,甚至更为简单。要做的就是一个DFS给每个位分配位置,若0没有用完,则先分配0。1没有用完,则接着分配1。最后将结果输出即可。
源代码:
#include
#define MAX 16+5
int N,H,onum,znum;...
分类:
其他好文 时间:
2014-09-27 18:16:30
阅读次数:
135