よう。動作しないように見えるこの非常に単純なスワップ機能があります。おそらくポインタの問題なので、アドバイスがあればいいでしょう。
void swap(pQueue *h, int index1, int index2) {
student *temp = &h->heaparray[index1];
h->heaparray[index1] = h->heaparray[index2];
h->heaparray[index2] = *temp;
}
pQueue
はヒープ ポインターでindex1
あり、index2
有効なインデックスであることが保証されています。
student *temp
の値を取得しますが、 に一heaparray[index1]
時値heaparray[index2]
が割り当てられた場合、heaparray[index2]
は同じままです。アドバイスをいただければ幸いです。