C語言 鍊錶的建立,插入,刪除,列印

2021-09-01 05:45:31 字數 984 閱讀 3315

#include #include #include //結構體定義

struct node;

typedef struct node listnode;

//函式宣告部分

listnode* createlist(int n);

void insertlist(listnode *h,int i,char name,int score, int n);

void deletelist(listnode *h,int i,int n);

void printlist(listnode *h);

//函式實現部分

listnode* createlist(int n)

p->next = null;

return head;

}void printlist(listnode *h)

}//主函式

void main()

}}//插入鍊錶結點

void insertlist(listnode *h,int i,char name,int e, int n)

q = (listnode*)malloc(sizeof(listnode)); //為要插入的結點分配空間

strcpy(q->name,name);

q->score = e;

q->next = p->next;

p->next =q;

}}//刪除鍊錶結點

void deletelist(listnode *h,int i,int n)

q = p->next; //找到要刪除的q結點

p->next = q->next;

strcpy(name,q->name);

score = q->score;

free(q);

printf("name=%s,score=%d\n",name,score);

}}

C語言鍊錶的插入和刪除 建立

choicetxt.h 執行要重複的 選擇執行的醒目並將結果付給choice include stdio.h int choicetxt int choice else creat.c include stdio.h include stdlib.h include define.h extern ...

C語言習題 鍊錶建立,插入,刪除,輸出

web board problemset standing status statistics time limit 1 sec memory limit 128 mb submit 1389 solved 687 submit status web board 編寫乙個函式creatlink,用來...

鍊錶建立 插入 刪除

這兩天,拼命理解鍊錶,儘管現在理解還是不夠,但終於把長久以來一直折磨我的鍊錶用c 打出來了。還是有點小小的成就感。以下是 包括鍊錶建立 頭插法和尾插法 插入乙個位置的鍊錶 刪除乙個位置的鍊錶以及整個鍊錶的刪除。define null 0 include using namespace std int...