-
算法实现题2
算法实现题2-9 排列的字典序问题
« 问题描述:
n个元素{1,2, , n }有n!个不同的排列。将这n!个排列按字典序排列,并编号为0,1,…,
n!-1。每个排列的编号为其字典序值。例如,当n=3时,6 个不同排列的字典序值如下:
字典序值 0 1 2 3 4 5
排列 123 132 213 231 312 321
« 编程任务:
给定n 以及n 个元素{1,2, , n }的一个排列,计算出这个排列的字典序值,以及按字
典序排列的下一个排列。
« 数据输入:
由文件input.txt提供输入数据。文件的第1 行是元素个数n。接下来的1 行是n个元素
{1,2, , n }的一个排列。
« 结果输出:
程序运行结束时,将计算出的排列的字典序值和按字典序排列的下一个排列输出到文件
output.txt中。文件的第一行是字典序值,第2行是按字典序排列的下一个排列。
输入文件示例 输出文件示例
input.txt output.txt
8
2 6 4 5 8 1 7 3
8227
2 6 4 5 8 3 1 7
- 2022-02-12 05:10:54下载
- 积分:1
-
同样是讲电路高速设计的资料,希望帮助大家
同样是讲电路高速设计的资料,希望帮助大家-The same stresses of high-speed circuit design information, in order to help U.S.
- 2022-11-07 00:45:04下载
- 积分:1
-
LC分枝限界法解货郎担―代码
LC分枝限界法解货郎担―代码-LC Branch and Bound Solving traveling salesman- code
- 2022-05-29 05:55:59下载
- 积分:1
-
Image edge detection software, ready to work together to force a friend in China...
图像边缘检测软件,愿与广大朋友共同合作至力于中国的源代码开发事业-Image edge detection software, ready to work together to force a friend in China to develop the cause of the source code
- 2022-11-20 14:20:03下载
- 积分:1
-
vb编写的一个实现主明细报表的一个压顶枯无可奈何花落去
vb编写的一个实现主明细报表的一个压顶枯无可奈何花落去-vb prepared a detailed statement of the realization of the main roof of a pressure can do nothing about the flowers to dry
- 2022-02-21 02:20:37下载
- 积分:1
-
实现创建一个三元组,取三元组的任意一个分量,置三元组的任意一个分量,求三元组的最大分量,求三元组的最小分量,显示三元组等基本操作。...
实现创建一个三元组,取三元组的任意一个分量,置三元组的任意一个分量,求三元组的最大分量,求三元组的最小分量,显示三元组等基本操作。-achieve the creation of a Group 3, Group 3 yuan from an arbitrary weight, home Triples an arbitrary weight, Group 3 yuan for the largest component, for the smallest group 3 weight, Group 3 shows the basic operation.
- 2022-03-10 13:49:49下载
- 积分:1
-
实现计算器基本功能,如基本的加减乘除,还有三角函数等
实现计算器基本功能,如基本的加减乘除,还有三角函数等-Achieve the basic function calculator
- 2022-12-26 20:20:04下载
- 积分:1
-
这是一个代理服务器程序它使用多线程
这是一个代理服务器程序它使用多线程-This is a proxy server procedures it uses multithreading
- 2022-11-20 19:10:03下载
- 积分:1
-
横断面自动生成程序
可以调用CAD自动绘图、可以在WORD下自动生成横断面成果表格,满足设计和工程方量计算的需要
- 2022-12-22 04:50:09下载
- 积分:1
-
该程序是利用概率算法,可以在该算法中设置大小…
这个程序是利用概率算法求可设大小得素数。-the procedure is the use of probabilistic algorithm can be set up for size in the prime.
- 2023-09-09 00:20:03下载
- 积分:1