/*單向連結串列的反向輸出*/
#include
#define MAX_LEN 10
typedef struct _LINKNODE
{
int value;
struct _LINKNODE *next;
}LINKNODE;
/*連結串列逆置的原理就是前插,把原連結串列中的元素一個一個的前插到新的連結串列中*/
LINKNODE* revertLink(LINKNODE* head)
LINKNODE* revert = NULL;
LINKNODE* temp = NULL;
while(head != NULL)
temp = head->next;
head->next = revert;
revert = head;
head = temp;
}
return revert;
void main()
int array[MAX_LEN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
LINKNODE* head = NULL;
LINKNODE* curNode = NULL;
for(int i=0; i
/*單向連結串列的反向輸出*/
#include
#include
#define MAX_LEN 10
typedef struct _LINKNODE
{
int value;
struct _LINKNODE *next;
}LINKNODE;
/*連結串列逆置的原理就是前插,把原連結串列中的元素一個一個的前插到新的連結串列中*/
LINKNODE* revertLink(LINKNODE* head)
{
LINKNODE* revert = NULL;
LINKNODE* temp = NULL;
while(head != NULL)
{
temp = head->next;
head->next = revert;
revert = head;
head = temp;
}
return revert;
}
void main()
{
int array[MAX_LEN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
LINKNODE* head = NULL;
LINKNODE* curNode = NULL;
LINKNODE* temp = NULL;
LINKNODE* revert = NULL;
for(int i=0; i