【算法】递归回溯算法(C++源码)
一、任务描述:
采用递归回溯法设计一个算法,求从1~n的n个整数中取出m个元素的排列,要求每个元素最多只能取一次。例如,n=3,m=2的输出结果是(1,2),(1,3),(2,1),(2,3), (3,1),(3,2)。
二、要求
选取不同的n和m测试所设计的上述算法
三、运行结果截图:
四、源代码(C++)
采用递归回溯法设计一个算法,求从1~n的n个整数中取出m个元素的排列,要求每个元素最多只能取一次。例如,n=3,m=2的输出结果是(1,2),(1,3),(2,1),(2,3), (3,1),(3,2)。
选取不同的n和m测试所设计的上述算法
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M