Q:

Inserting new score into sorted array while updating separate array of names

score is an array of 10 scores in ascending order.
scoreName is an array of names associated with with each score.
I need to check if a new score is good enough to enter the the high score table and if so, insert it into the correct position and make sure scoreName is also updated to reflect any changes.
I am having problems with my current code:
//Table
for (int i = 0; i < leaderBoardSize; i++)
        {
            cout << scoreName[i] << "\t\t" << score[i] << endl;
        }
        system("pause");

        //Check to see if you made the highScore
        if (diceTotal >= score[9])
        {
        cout << "Congrats, you have made the HighScore Table !\nEnter Your Name.";

            cin >> playerName;

            for (int i = 9; i < leaderBoardSize; i--)
            {

                if (diceTotal <= score[i])
                {
                    scoreName[i = i + 1] = scoreName[i];
                    score[i = i + 1] = score[i];

                    scoreName[i] = playerName;
                    score[i] = diceTotal;
                    break;
                }

                    scoreName[i = i + 1] = scoreName[i];
                    score[i = i + 1] = score[i];

            }
        }

Here is the entire code:
    #include <iostream>
#include <string>
#include <time.h>
using namespace std;
int main()
{
    //dice game variables
    int dice1 = 0;
    int dice2 = 0;
    int diceTotal = 0;
    int round = 0;

    string choice;
    bool isDone = true;

    //Scoreboard 
    const int leaderBoardSize = 10;
    int score[10] = { 40, 33, 29, 24, 22, 19, 15, 12, 11, 9 };
    string scoreName[leaderBoardSize] = { "Jason", "Steve", "Bob", "Timberduck",    "Eric", "Susan", "Tyler", "Nick", "NinjaDave", "RaidenGunfire" };
    string playerName;

    //random number seeder
    srand((unsigned int)time(NULL));

    //Game instructions
    cout << "dice game\n---------\nCreated By: Darcy Tellier\n--------------------------\nInstructions:\nRoll 2 dices. Try to get as close to 50 without going over." << endl;

    //The Game loop
    do
    {
        //resets game variables
        diceTotal = 0;
        round = 1;

        //in game match loop
        do
        {
            // display round #, current dice total, ask user to quit or re-roll.
            cout << "Round\n-----\n  " << round << endl;
            cout << "current total:" << diceTotal << endl;
            cout << "Roll dice (y/n)?";
            cin >> choice;

            //Checks the users imput for invalid characters 
            while (choice != "Y" && choice != "y" && choice != "N" && choice != "n")
            {
                cout << "invalid option. Choose y/n:" << endl;
                cin >> choice;
            }

            if (choice == "Y" || choice == "y")
            {
                //roll dice
                round += 1;
                dice1 = rand() % 6 + 1;
                dice2 = rand() % 6 + 1;
                diceTotal = diceTotal + dice1 + dice2;
                cout << "you have rolled a " << dice1 << " and a " << dice2 <<   endl;

                if (diceTotal > 50)
                {
                    isDone = false;
                }
            }
            else
            {
                //break was used because "isDone = false" does not work here. The debugger shows that when the variable is set to false, it still ignores it and skips  to the next round. 
                break;
            }

        } while (isDone == true || diceTotal < 50);

        //end of round
        if (diceTotal > 50)
        {
            cout << "\nGameOver" << endl;
            cout << "You went over in " << round << " turns. You Lose!!! " << endl;
        }
        else
        {
            cout << "You stopped at " << round << " turns. Final score: " <<  diceTotal << "." << endl;
            system("pause");
            system("cls");
        }
        //Table

        for (int i = 0; i < leaderBoardSize; i++)
        {
            cout << scoreName[i] << "\t\t" << score[i] << endl;
        }
        system("pause");

        //Check to see if you made the highScore
        if (diceTotal >= score[9])
        {
            cout << "Congrats, you have made the HighScore Table !\nEnter Your       Name.";

            cin >> playerName;

            for (int i = 9; i < leaderBoardSize; i--)
            {

                if (diceTotal <= score[i])
                {

                    scoreName[i] = playerName;
                    score[i] = diceTotal;
                    break;
                }

            }
        }
        //board display #2
        for (int i = 0; i < leaderBoardSize; i++)
        {
            cout << scoreName[i] << "\t\t" << score[i] << endl;
        }
        system("pause");
        //do you want to play again?
        cout << "Do you want to play again";
        cin >> choice;
        while (choice != "Y" && choice != "y" && choice != "N" && choice != "n")
        {
            cout << "invalid option. Choose y/n:" << endl;
            cin >> choice;
        }

        if (choice == "Y" || choice == "y")
        {
            system("cls");
            isDone = true;
        }
        else
        {
            cout << "game over" << endl;
            isDone = false;
        }
    } while (isDone);

    system("pause");

    return 0;
    }

This is a copy of the assignment.
Note: I am not asking for you guys to do my work. I just want to figure out the highScore sorting thing.
 

A:

The problem: arrays are not a good way to achieve what you want
You are trying to see if a score beat another score, and if so, replace that and move the rest of the scores down. I assume your scores are sorted, and that score is a int[10], but you have several problems:
1.
for (int i = 9; i < leaderBoardSize; i--)

You are attempting to iterate through your scores backwards, so you start at 9 (which I assume is the last index) and work your way down. Assuming leaderBoardSize is the total size of the leaderboard, and likely 10, i will always be less than leaderBoardSize and your for loop will go for a loooong time. You probably meant to say:
for (int i = 9; i >= 0; i--)

2.
scoreName[i = i + 1] = scoreName[i];
score[i = i + 1] = score[i];

This is assigning i to a new value, which will also ruin your for loop. You should only be doing
scoreName[i + 1] = scorename[i];

Trying to swap all the values in an array in cumbersome, and you are trying to do everything manually, so I give you:
The solution: use the standard library!
C++ is a great language, if for no other reason than containing a standard library: a library of functions and classes that solve many basic problems for you.
It is far easier to sort, insert and remove elements by using a standard container. Let's use std::vector:
// Simple class to handle a player score: a name and score
struct PlayerScore
{
    std::string name;
    unsigned int score;
};

// Create some test scores. I assume you have another means of storing high scores, perhaps in a file, but for this small purpose I am just hard-coding some scores:
std::vector<PlayerScore> hiScores = { {"ABC", 5000}, {"XJK", 10000}, {"FOO", 20000}, {"EGG", 4000}, {"HI", 50000} };

You may keep your scores sorted, but if, like mine they aren't sorted, you can sort them easily with std::sort:
std::sort(hiScores.begin(), hiScores.end(), [](PlayerScore ps1, PlayerScore ps2){ return ps1.score > ps2.score; });

With that out the way, you can proceed to play your game and obtain a name for the player and their score. I haven't bothered, and will just create a value for the score:
auto score = 10123u;
// Check if this score beats any of the current high scores:
auto it = std::find_if(hiScores.begin(), hiScores.end(), [score](PlayerScore ps){ return score > ps.score; });
if (it != hiScores.end())
{
    // Yes! We beat a score!
    std::cout << "Found score: " << it->score << std::endl;
    // Insert this score before the other score
    hiScores.insert(it, {"NewScore", score});
    // Remove the last score:
    hiScores.pop_back();
}

You no longer need to iterate and manually try to manipulate the positions of scores. Standard containers with random access such as std::vector allow you to just insert and access elements as you need to. Your 10 lines of code simply becomes 2 lines. std::vector also manages the size for you, so if you only have 3 high scores initially, it can grow easily to contain 10, 100 or many more scores.
std::find_if can find an element in your container without the need to manually iterate over every element. A predicate is passed in which acts as a find condition, which in our case we pass our score and check if it's greater than any PlayerScore in the container. The first element it's greater than is returned to us, and then we can insert our score in front of it, then remove the last score via pop_back

