Question: Programming in C need help/correction with topTen function (will be called from menu in main) (score range is 17-100, lower the better) (battleship) function will
Programming in C
need help/correction with topTen function (will be called from menu in main) (score range is 17-100, lower the better) (battleship)
function will need to be able to:
Display top ten scores
A playCount will be needed to keep track of how many games
get score from a finish game, place and or compare it to scores in array and place it in the array if it makes the top ten (topTen array will need to be saved in bin file so it will be able to be compared each time),
must account for if < 10 games (just place in array) have been played and if 10 games have been played (games cap will be 10)
my code is below but only need help with topTen function please reference it. will have to prototype at top of main and call function in main.
void topTen(int score[], int newScore) { //Show the top ten scores
int i, count, temp, pass, n = 0, j;
for (i = 0; i < GAMES; i++) {
if (score[i] == 0) {
score[i] = newScore;
i = 10;
}
}//End loop
//Checks the newest score against all the other scores stored in the array.
if (newScore < score[GAMES - 1])
score[GAMES - 1] = newScore;
// sort scores in array using insertion method
for (i = 1; i < n; i++) {
}
for (i = 0; i <= n - 1; i++) {
j = i;
}
CLS;
printf("\t\t\tTop Ten Scores ");
for (i = 0; i < (GAMES); i++) {
if (score[i] == 0) {
printf("\t\t\t%02d: Empty Score ", i + 1);
}
else {
printf("\t%02d: %d Moves ", i + 1, score[i]);
}
}
PAUSE;
}// end topTen
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
