鍊錶的增刪改查

2021-08-09 19:57:28 字數 1396 閱讀 6464

#include

#include

#define true 1

#define false 0

int s = 0; //定義全域性變數s接收查詢資料的位置

//結點型別定義

typedef

struct linknode

node;

//構造鍊錶(帶頭結點的尾插法建表)

node* create_list()

tail->next = null;

printf("鍊錶建立成功!\n");

return head;

}//輸出鍊錶

void output_list(node *head)

printf("\n");

}//求鍊錶長度

int length_list(node *head)

return len;

}//判斷鍊錶是否為空

int empty_list(node *head)

//刪除鍊錶中某個元素

int delete_list(node *head, int pos, char *val) // pos(從1開始)代表你要刪除鍊錶中第幾個元素

//插入某個元素

int insert_list(node *head, int pos, char data)

//在鍊錶中按值查詢

int search_list(node *head, char data) //在鍊錶中查詢和data相同的數

p = head->next;

while (p != null && p->data != data)

if (p != null)

printf("未找到值為%c的點\n",data);

return

false;

}int main()

case

2: //插入

break;

}case

3: //刪除

printf("鍊錶遍歷為: ");

output_list(head);

break;

}case

4: //顯示

printf("鍊錶遍歷為: ");

output_list(head);

break;

}case

5: //查詢

case

6: //求鍊錶長度

case

0: //輸入0結束}}

}

mysql增刪改查鍊錶 鍊錶的增刪改查

include include 先定義鍊錶裡面的元素。typedef struct nodemynode 定義整個鍊錶。typedef struct linkmylink int isempty to mylink mylink mylink 判斷鍊錶是否為空。int push to mylinki...

鍊錶 增刪改查

實現 鍊錶的增刪改查 package com.baicai.linkedlist public class singlinkedlistdome 定義乙個singlinkedlist管理我們的英雄 class singlelinkedlist 如果沒有找到最後的乙個節點就直接往後面找 temp te...

鍊錶的增刪改查

include include define len sizeof preson 測結構體preson的長度,並定義常量,給後面的動態開闢空間提供方便 union clas position 共用體 老師和學生的描述不同,學生用班級,老師用職位 typedef struct presons 定義pr...