//單鏈表的常用基本操作.cpp
#include
using namespace std;
typedef struct nodelistnode;
listnode* create_emptylist(void) //建立空鍊錶,帶頭結點------------1
void insert_list(listnode *list,listnode *pos,listnode x) // 在pos後插入x-------------2
listnode *temp=new listnode;
strcpy(temp->name,x.name);
temp->age=x.age;
temp->score=x.score;
temp->next=pos->next;
pos->next=temp;
}void delete_list(listnode* list,listnode* pos) //刪除pos之後的結點-------------3
if(pos->next==null)
listnode *temp=pos->next;
pos->next=temp->next;
delete temp;
}int get_length(listnode* list) //計算鍊錶長度(元素個數)----------4
return length;
}listnode* get_position(listnode* list,int order) //根據元素所在的位序,得到其位置值----5
listnode* t=list->next;
int num=1;
while(numnext;
}return t;
}void browser(listnode *list) //遍歷鍊錶(輸出各元素值)-------6
listnode* get_tail(listnode* list) //得到鍊錶的尾結點位置-----7
void delete_list_order(listnode* list,int order) //刪除單鏈表中指定序號的元素-----8
void main(void)
browser(mylist);
cout<<"the length of the list is "cout<<"after delete the node after no.2/n";
cout<<"the length of the list is "cout<<"after delete the first node:/n";
cout<<"the length of the list is "<
單鏈表基本操作
include include include include includeusing namespace std typedef struct node node,plinklist plinklist createfromhead node pstnode node malloc sizeof...
單鏈表基本操作
單鏈表的初始化,建立,插入,查詢,刪除。author wang yong date 2010.8.19 include include typedef int elemtype 定義結點型別 typedef struct node node,linkedlist 單鏈表的初始化 linkedlist...
單鏈表基本操作
include using namespace std define namelenth 20 define ok 0 define error 1 typedef struct flagnode node 生成結點 inline node newnode 銷毀化煉表 void destroylin...