My sorting algorithm keeps turning out 10-15 each of the same number its suppose to sort my array which has a size of 2000 with numbers from 1-100. It's a homework assignment I've only been coding in C++ for 4 months and I've been working on it bout all day and it's due 12:00. Please help. Just can't figure out the algorithm
//Function to sort the numbers
void sortNumbers(int nums[], int ARRAY_SIZE) {
int startScan, minIndex, minValue;
for (startScan = 0; startScan < (ARRAY_SIZE-1); startScan++) {
minIndex = startScan;
minValue = nums[startScan];
for(int index = startScan+1; index < ARRAY_SIZE; index++) {
if(nums[index]< minValue) {
minValue = nums[index];
minIndex = index;
}
nums[minIndex] = nums[startScan];
nums[startScan] = minValue;
}
}
}
printfstatements). Institutions tend to concentrate on coding when the most important skill is debugging. IMNSHO.keeps turning out 10-15 each of the same number, you are aware that 2000 numbers all in the range 1-100 will average about 20 copies of each number, right? And, if you sort them, that's what you'll see:1 1 1 1 1 2 2 2 2 3 3 3 3...(but with about 20 of each). Are you sure you're not just tilting at windmills?