我不知道如何使排序选择起作用。我必须按升序对结构中的分数(双打)进行排序。
这是我的代码,我会评论我在哪里得到错误。
我的结构:
struct diveInfo
{
string diversName;
double totalScore;
double totalScore;
double diff;
double scores[NUM_SCORES];
};
我按升序对分数进行排序的功能:
void selectionSort(diveInfo *ptr, int size)
{
diveInfo temp;
double minValue;
int startScan;
int minIndex;
for ( startScan = 0; startScan < (size - 1); startScan++)
{
minIndex = startScan;
minValue = ptr[startScan].scores; //keep getting an error here saying type double cannot be assigned to an entity of type double.
temp = ptr[startScan];
for (int index = startScan + 1; index < size; index++)
{
if ( ptr[index].scores < minValue)
{
temp = ptr[index];
minIndex = index;
}
}
ptr[minIndex] = ptr[startScan];
ptr[startScan] = temp;
}
}