Randide algorithm for any string (can have a repetitive character)

zhaozj2021-02-16  48

/ (Name: Liang Xun // Study: 02D470 // Completion Time: 10/8/2002 // File Name: 1.cpp /

#define n 21 # include #include

// declaration. Char d [n]; void permutation (char s [], int 1; void sort (char s []); int count = 0;

Void main () {char s [n];

// Enter the source string. Printf ("Please enter a string of no more than 20 characters:"); gets (s);

// Sort, arrange and output. Sort (s); Permutation (s, 0, strlen (s));}

// Use the recursive output of various arrangements. Void Permutation (CHAR S [], INT I, INT N) {INT J; Char Temp; for (j = 0; j

// Sort. Void Sort (Char S []) {INT N = Strlen (S); INT I, J; Char Temp; for (i = 0; i s [j]) {temp = s [i]; s [i] = s [j]; s [j] = temp;}}}

转载请注明原文地址:https://www.9cbs.com/read-24423.html

New Post(0)