Here is my code...
This is a multi player mastermind game, now i'm stuck with how to sort the participant with their attempts?? And if their attempts is same, it will sort with respect to the time??Code:void Show_Ranking(float Time_Diff[], int Attempts[], int No_Participants, char Name_Participants[][128]) { int smallest_value; int start_value; int current_value; int ctrl; for(start_value=0; start_value<No_Participants; start_value++) { smallest_value=start_value; for(current_value=start_value+1; current_value<No_Participants; current_value++) { if(Attempts[current_value] < Attempts[smallest_value]) { smallest_value=start_value; } else if(Attempts[current_value] == Attempts[smallest_value] && Time_Diff[current_value]<Time_Diff[smallest_value]) { smallest_value=start_value; } } swap(Attempts[start_value],Attempts[smallest_value]); swap(Name_Participants[start_value],Name_Participants[smallest_value]); } for(ctrl=0; ctrl<No_Participants; ctrl++) { cout << ctrl+1 << "\t" << Name_Participants[ctrl]; cout << endl; } }



LinkBack URL
About LinkBacks



