choicetxt.h
//執行要重複的**,選擇執行的醒目並將結果付給choice
#include"stdio.h"
int choicetxt()
int choice()
else}}
creat.c
#include"stdio.h"
#include"stdlib.h"
#include"define.h"
extern count;
struct stulist *creat()
printf("/t請輸入姓名:");
fflush(stdin);
scanf("%s",pc->stuname);
printf("/t請輸入學號:");
fflush(stdin);
scanf("%d",&pc->stuid);
printf("/t請輸入成績:");
fflush(stdin);
scanf("%d",&pc->stsoult);
if(count==0)
head = pf = pc;
else pf->next = pc;//前一條紀律的next指向當前記錄
count++;
pc->next = null;
pf = pc;
printf("/t是否還要輸入:");
scanf("%d",&yn);
if(yn == 0 )
return head;}}
define.h
// 定義用於鍊錶的結構
struct stulist
;dele.c
#include"stdio.h"
#include"define.h"
#include"stdlib.h"
struct stulist *dele(struct stulist *head)
printf("/t請你輸入你要刪除的的學生學號:");
scanf("%d",&numid);
back = head;
if(head->stuid == numid)
pf = back;
back=back->next;
while(back != null)
pf = back;
back=back->next;
}printf("/n/t沒有你要刪除的學生:/n");
return head;
}display.c
#include"stdio.h"
#include"define.h"
void disp(struct stulist *head)
}insert.c
#include"stdio.h"
#include"stdlib.h"
#include"define.h"
extern count;
struct stulist * insert(struct stulist *head)
printf("/n/t請輸入要插入的位置:");
scanf("%d",&numid);
pc = head;
while (pc !=null)
back=pc;
pc=pc->next;
}pi->next=null;
back->next=pi;
count++;
return head;
}linklist.c
#include"stdio.h"
#include"choicetxt.h"
#include"define.h"
int count=0;
struct stulist *creat();
void disp(struct stulist *head);
struct stulist *insert(struct stulist *head);
struct stulist *dele(struct stulist *head);
void main()
else
case 3:
head=insert(head);
break;
case 4:
head = dele(head);
break;
case 5:
return;}}
}
C語言 鍊錶的建立,插入,刪除,列印
include include include 結構體定義 struct node typedef struct node listnode 函式宣告部分 listnode createlist int n void insertlist listnode h,int i,char name,int...
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...