water question: list all the questions and find the smallest rank.
# Include <iostream> # include <string> # include <memory. h> using namespace STD; string hold = "ABCDE"; string result; string a [101]; int total; void all_permutation (INT current); int calculate (); int find (char); int Mini, N; bool used [5]; int main () {While (CIN> N & N) {memset (used, false, 5 * sizeof (bool); For (INT I = 0; I <n; I ++) CIN> A [I]; Mini = calculate (); result = hold; all_permutation (0); cout <result <"Is the median ranking with value" <mini <". "<Endl;} return 0;} void all_permutation (INT current) {If (current> = 5) {Total = calculate (); If (total <mini) {mini = total; Result = hold ;}} else {for (INT I = 0; I <5; I ++) if (! Used [I]) {used [I] = true; hold [current] = I + 'a'; all_permutation (current + 1 ); used [I] = false ;}} int calculate () {int result = 0; For (INT I = 0; I <n; I ++) {for (Int J = 0; j <4; j ++) {for (int K = J + 1; k <5; k ++) {If (find (A [I] [J])> Find (A [I] [k]) Result ++ ;}} return result ;} int find (char X) {int index; For (INT I = 0; I <5; I ++) {If (hold [I] = X) {Index = I; Return Index ;}}}