單鏈表倒序算法
typedef struct node
{
int i;
struct node* next;
}LNode;
void DeOrder(LNode*& aNode)
{
if (aNode->next == NULL)
{
return;
}
LNode* temp1 = NULL;
LNode* temp2 = aNode->next;
do
{
aNode->next = temp1;
temp1 = aNode;
aNode = temp2;
temp2 = aNode->next;
}while(temp2 != NULL);
aNode->next = temp1;
}
{
int i;
struct node* next;
}LNode;
void DeOrder(LNode*& aNode)
{
if (aNode->next == NULL)
{
return;
}
LNode* temp1 = NULL;
LNode* temp2 = aNode->next;
do
{
aNode->next = temp1;
temp1 = aNode;
aNode = temp2;
temp2 = aNode->next;
}while(temp2 != NULL);
aNode->next = temp1;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.