Copy codeThe Code is as follows: # include <stdio. h>
# Include <string. h>
# Include <malloc. h>
Void q_sortB (char str [20] [20], int n );
Void qs (char str [20] [20], int n );
Void main (){
Int I, n;
Char str [20] [20] ={{ "Adam" },{ "Bob" },{ "Dimen" },{ "Colin "},{
"Correal" },{ "Sick" },{ "Rachel "}};
Char * str1 [20] ={{ "Adam" },{ "Bob" },{ "Dimen" },{ "Colin "},
{"Correal" },{ "Sick" },{ "Rachel "}};
Qs (str, 7 );
Q_sortB (str, 7 );
For (I = 0; I <7; I ++ ){
Printf ("% s \ n", str [I]);
}
}
Void qs (char str [20] [20], int n ){
Char temp [20];
Int I = 0;
Int j = 0;
Int min = I;
For (I = 0; I <n-1; I ++ ){
Min = I;
For (j = I; j <n; j ++) {// the minimum value range for this query is from I to the end.
If (strcmp (str [j], str [min]) =-1 ){
Min = j;
}
}
// At this time, min points to the smallest
// Put min in the last one of the sorted parts // that is, the first one in this sorting.
Strcpy (temp, str [I]);
Strcpy (str [I], str [min]);
Strcpy (str [min], temp );
}
}
// Bubble
Void q_sortB (char str [20] [20], int n ){
Char a [20];
Int I, j;
For (I = 0; I <n-1; I ++ ){
For (j = I; j <n-1; j ++)
If (strcmp (str [j], str [j + 1])> 0 ){
Strcpy (a, str [j]);
Strcpy (str [j], str [j + 1]);
Strcpy (str [j + 1], );
}
}
}