Description: The algorithm realizes the dictionary order problem of 2-9 permutation
Description of laquo:
N elements {1,2, 61516, n} have n! A different arrangement. The n! The list is arranged in a dictionary and numbered 0, 1... ,
N! 1. The number of each rank is its dictionary order value. For example, when n= 3, the order values of the six different sequences are as follows:
Dictionary order is 0, 1, 2, 3, 4, 5
Permutation: 123 132 213 231 312 321
« programming tasks:
Given n and n elements {1,2, 61516, n}, compute the lexicon of this arrangement, and by word
The next permutation of the ordinal sequence.
« data input:
Input data is provided by input.txt. The first line of the file is the number of elements n. The next one is going to be n elements
{1,2, 61516, n}.
« result output:
At the end of the program run, the sorted dictionary order values are calculated and the next permutation in the lexicon is output to the file
The output. TXT. The first line of the file is the dictionary sequence, and line 2 is the next sequence in the lexicon.
An example of the input file example output file
Input. TXT output. TXT
8
2, 6, 4, 5, 8, 1, 7, 3
8227
2, 6, 4, 5, 8, 3, 1, 7
- [N queen problem] - Put on N queens in a N multiply N chessb
- [stir] - classical algorithm that-- Set demarcati
- [prog26] - classical algorithm that-- half the sing
- [PIPE] - The problem of pipeline problem of 2-1 o
- [aknight] - The problem of combat horse was realized
- [code] - Algorithm acm C++
File list (Check if you may need any files):