Input:
Given the number of data N, then enter n numbers to find all the numbers.
Output:
Output the number of all arrays.
Sample input:
3
1 2 3
Sample output:
123
132
213
231
312
321
Ideas:
It is also a typical example of recursive solution.
The Code is as follows:
<Span style = "font-size: 14px;" >#include <stdio. h> # include <string. h> int A [110], B [110], C [110]; int N; void res (INT Len) {If (LEN> = N) // recursive end condition {for (INT I = 0; I <n; I ++) printf ("% d", C [I]); puts (""); return;} For (INT I = 0; I <n; I ++) {If (! B [I]) // use B [I] to determine whether a previous {B [I] = 1; C [Len] = A [I]; // copy the value to the array C [I] for output data res (LEN + 1); // perform a series of recursive B [I] = 0; // ensure that multiple groups of data can be output.} int main () {While (~ Scanf ("% d", & N) {for (INT I = 0; I <n; I ++) scanf ("% d ", & A [I]); // A [I] is used to temporarily store the element memset (B, 0, sizeof (B); // initialization, B [I] is used to mark res (0);} return 0 ;}</span>
Full combination of Recursive Algorithms