大学のプロジェクトでバブルソートを実装しようとしましたが、いくつか問題があります。 私がそれを手伝ってくれれば幸いです。C++のリンクリストのバブルソート
void TrainManagerLinkedList:: Swap(TrainManager & x,TrainManager & y)
{
TrainManager temp;
temp =x;
x = y;
y = temp;
}
void TrainManagerLinkedList::BubbleSort()
{
TrainManagerLink* outerCurr = this->m_head;
TrainManagerLink* curr = NULL;
while(outerCurr != NULL)
{
curr = this->m_head;
while(curr != NULL && curr->m_next != NULL)
{
/*if the current link greater then the next swap between them*/
if (curr->m_data->GetDate() > curr->m_next->m_data->GetDate())
{
Swap(&(curr->m_data),&(curr->m_next->m_data));
}
else if((curr->m_data->GetDate() == curr->m_next->m_data->GetDate())&(curr->m_data->GetTime() > curr->m_next->m_data->GetTime()))
{
Swap(&(curr->m_data),&(curr->m_next->m_data));
}
curr = curr->m_next;
}
outerCurr = outerCurr->m_next;
}
/*now the list is sorted :)*/
}
私のデータ型
TrainManagerLink *m_head;
TrainManagerLink *m_tail;
int m_numOfElements;
class TrainManager
{
char * m_firstStation;
char *m_lastStation;
char * m_origin;
char * m_destination;
int m_timeBetweenStations;
Hour m_releaseTime;
Hour m_arriveTime;
Hour m_firstHour;
Date m_Date;
int m_standInstation;
DelayersLinkedList delay;
}
リンクリストは、日付と時間順にソートされなければなりません。 しかし、私はいくつかのコンパイルの問題があります。 私はあなたの助けを必要としています ありがとう、
コードをすべてコードとしてフォーマットできますか?ありがとうございました! –
コンパイラエラーの正確な言葉は何ですか? –
この質問にはかなりのコンテキスト情報がありません。 [あなたの問題について正確かつ情報をお持ちください](http://www.catb.org/~esr/faqs/smart-questions.html#beprecise)、[コードについて質問する](http://www.catb.org/~esr/faqs/smart-questions.html#beprecise) /www.catb.org/~esr/faqs/smart-questions.html#code)と[「完璧な質問を書く」](http://tinyurl.com/so-hints)を参照してください。 – outis