So here is what I still have:
void sortArray(int amountOfScores, int* testScores)
{
for(int i = 0; i < amountOfScores; i++)
{
for(int j = 0; j < amountOfScores-1; j++)
{
if(*(testScores+i) > *(testScores+j+1))
{
int temp = *(testScores+j);
*(testScores+j) = *(testScores+j+1);
*(testScores+j+1) = temp;
}
}
}
for(int i = 0; i < amountOfScores; i++)
{
cout << *(testScores+i) << endl;
}
}
Basically, I try to read, no matter how many user numbers you enter, and then sort them in ascending order. To catch, I have to use pointers, and I never understood them. This code above works for 3 numbers, however, it adds even more reasons not to sort them ... I tried the shooting problem as much as I could, but without any knowledge in the pointers. I do not know what I am looking for.
Thanks for the help!
source
share