請(qǐng)問(wèn)遍歷節(jié)點(diǎn)時(shí),兩個(gè)語(yǔ)句是否可以調(diào)換位置
crt?=?crt->next; crt->printnode(); 如果我先打印當(dāng)前節(jié)點(diǎn)的數(shù)據(jù)域,在將下一個(gè)節(jié)點(diǎn)作為當(dāng)前節(jié)點(diǎn)(next),似乎也可以?
crt?=?crt->next; crt->printnode(); 如果我先打印當(dāng)前節(jié)點(diǎn)的數(shù)據(jù)域,在將下一個(gè)節(jié)點(diǎn)作為當(dāng)前節(jié)點(diǎn)(next),似乎也可以?
2019-10-21
舉報(bào)
2019-11-10
你可以這樣
crt?=?crt->next;
while (currentNode != NULL) {crt->printnode();crt?=?crt->next;}不然你會(huì)在開(kāi)頭輸出一個(gè)0;因?yàn)檫@個(gè)課程的頭節(jié)點(diǎn)是NULL,所以你要在while循環(huán)的前面加crt?=?crt->next;