結構體與鍊錶上機題目 2023年12月13日

2021-09-03 02:12:00 字數 2509 閱讀 7805

結構體與鍊錶 2023年12月13日

以下內容僅供娛樂,歡迎隨時**,請多指教!

有如下的結構體:

typedef

struct link_list

stu,

*linklist;

利用此結構體設計單鏈表,並在單鏈表上完成如下操作:

(1) 建立鍊錶。

(2) 輸出鍊錶。

(3) 鍊錶查詢。

(4) 鍊錶插入。

(5) 鍊錶刪除。

#include

"stdio.h"

#include

"string.h"

#include

"stdlib.h"

//結構體

typedef

struct link_list stu,

*linklist;

//建立鍊錶函式

linklist createlist()

if(q)q->next=

null

;return head;

}//輸出鍊錶函式

void

ouput

(linklist head)

}//找學號函式

linklist find_num

(linklist head,

int num)

return head;

}//找位置函式

linklist find_pos

(linklist head,

int pos)

return head;

}//求長度函式

intlength_linklist

(linklist head)

return n;

}//插入函式

linklist insert_linklist

(linklist head,stu s,

int pos)

else

return head;

}//刪除函式

linklist delete_linklist

(linklist head,

int pos)

else

if(pos == n)

else

return head;

}//主函式

intmain()

printf

("輸入查詢的學號num(0 結束)\n");

scanf

("%d"

,&ni)

;while

(ni !=0)

stu s;

int num,pos;

printf

("輸入插入的位置(pos)和學生資訊\n");

scanf

("%d%d%s%s"

,&pos,

&s.num,s.***,s.name)

;insert_linklist

(head,s,pos)

;ouput

(head)

;printf

("輸入刪除的位置(pos)\n");

scanf

("%d"

,&pos)

;delete_linklist

(head,pos)

;ouput

(head)

;return0;

}

#include

"stdio.h"

#include

"stdlib.h"

struct student

;student *

create()

q->next=

null

;return head;

}void

print

(student *head)

intlength

(student *head)

student *

find_pos

(student *head,

int pos)

return head;

}void

insert

(student *head,

int age,

int pos)

student *

find_value

(student *head,

int age)

return head;

}void

delte_pos

(student *head,

int pos)

void

delte_value

(student *head,

int age)

if(r)

}void

main()

結構體與鍊錶預習

一 結構體的宣告 我們把又一定聯絡的變數放在一起定義,這就是結構體,如下 struct student int num char name 20 float score stu struct student a,b,c scanf d s f stu.num,stu.name,stu.score 以...

結束結構體與簡單鍊錶

1620 7 唐大智 2016年12月6日 連續第六十六天總結 內容 a 1 在定義結構體型別時,成員不能初始化,也不能指定除了static以外的儲存型別。2 結構體型別可以含自身型別的指標成員,但不能含自身型別的普通成員。3 型別定義 型別定義的本質是對乙個已存在的型別重新命名,並不是定義新的資料...

函式上機題目2023年11月23日

函式上機題目2018年11月23日 以下內容僅供娛樂,歡迎隨時 請多指教!1 寫乙個判斷素數的函式,在主函式輸入乙個整數,並輸出是否素數的資訊 include include intfun int n return1 intmain 2 寫兩個函式,分別求兩個正數的最大公約數和最小公倍數,用主函式呼...