鍊錶的新增,查詢,刪除

2021-10-01 21:45:03 字數 1397 閱讀 7420

#include

#include

struct node//結點結構體

;struct node *head=

null

;//無結點時指向空

struct node *tail=

null

;//頭尾指標

//建立鍊錶,包括尾新增和頭新增

void

addtail

(int data)

else

//tail=sta;

}

//兩者的結構體是相同的

//建立鍊錶,頭新增

void

addhead

(int data)

else

}//頭新增類似於倒序,尾新增是正序

#include

#include

struct node//節點結構體

;struct node *head=

null

;//無節點時指向空

struct node *tail=

null

;//頭尾指標

//建立鍊錶,包括尾新增和頭新增

void

addnode

(int data)

else

//tail=sta;

}//建立鍊錶,頭新增

void

addhead

(int data)

else

}//查詢指定的結點

struct node *

select

(int data)

middle=middle->next;

}//未找到

return

null;}

;//遍歷鍊錶

void

sea()}

intmain

(void);

// head;

int i;

for(i=

0; i<

10; i++

)sea()

;//遍歷鍊錶並輸出

/* struct node *pfind=select(19);

if(pfind!=null)

printf("%d\n",pfind->data);與找到對應結點相配的輸出

else printf("no\n");*/

return0;

}//鍊錶的刪除

void

free()

//不要忘記頭和尾的清空

head=

null

; tail=

null

;}

新增查詢刪除資料

package demo1 leo description 暫無 date created in 2020 11 27 18 03 public class mylist public mylist object element get set方法 public object getelement ...

建立和刪除表,新增 查詢 修改和刪除資料

建立資料庫 create database 建立表 建立表 use gocreate table 使用某個資料 heroid int name varchar 50 nickname varchar 50 char 2 sal int bir datetime 刪除表 把錶的結構和表的資料一起刪除 ...

SQL INSERT,批量新增 查詢新增

新增多條記錄 insert into tablename col1,col2,col3 select 3,4,5 union allselect 6,7,8 從另外的一張表中讀取多條資料新增到新錶中 insert into tablename col1,col2,col3 select a,b,c ...