顺序表 (头删 尾删 清空)

cs 复制代码
//头删                                                  |  1 #include "head.h"                                       |  1 #ifndef ww
 87 void head_del(p lp)                                     |  2 int main(int argc, const char *argv[])                  |  2 #define ww
 88 {                                                       |  3 {                                                       |  3 #include <stdio.h>
 89     if(lp==0)                                           |  4     p lp=create_list();                                 |  4 #include <string.h>
 90     {                                                   |  5     int num1=empty_list(lp);                            |  5 #include <stdlib.h>
 91         printf("入参为空\n");                           |  6     if(num1==1)                                         |  6 #define max 7
 92         return;                                         |  7     {                                                   |  7 typedef struct list
 93     }                                                   |  8         printf("参数为空\n");                           |  8 {
 94     if(empty_list(lp))                                  |  9     }                                                   |  9     int arr[max];
 95     {                                                   | 10     else                                                | 10     int len;
 96         printf("参数为空无需删除\n");                   | 11         printf("参数不为空\n");                         | 11 }list,*p;
 97         return;                                         | 12     head_insert(lp,10);                                 | 12 
 98     }                                                   | 13     head_insert(lp,20);                                 | 13 //创建
 99     //元素循环前移覆盖                                  | 14     head_insert(lp,30);                                 | 14 p create_list();
100     for(int i=1;i<lp->len;i++)                          | 15     head_insert(lp,40);                                 | 15 //判空
101     {                                                   | 16     head_insert(lp,50);                                 | 16 int empty_list(p lp);
102         lp->arr[i-1]=lp->arr[i];                        | 17     head_insert(lp,60);                                 | 17 //判满
103     }                                                   | 18     end_insert(lp,100);                                 | 18 int full_list(p lp);
104     lp->len--;                                          | 19     head_del(lp);                                       | 19 //头插
105 }                                                       | 20     tail_del(lp);                                       | 20 void head_insert(p lp,int n);
106 //尾删                                                  | 21     clear_list(lp);                                     | 21 //输出
107 void tail_del(p lp)                                     | 22     show(lp);                                           | 22 void show(p lp);
108 {                                                       | 23     return 0;                                           | 23 //尾插
109     if(lp==0)                                           | 24 }                                                       | 24 void end_insert(p lp,int n);
110     {                                                   |~                                                           | 25 //头删
111         printf("入参为空\n");                           |~                                                           | 26 void head_del(p lp);
112         return;                                         |~                                                           | 27 //尾删
113     }                                                   |~                                                           | 28 void tail_del(p lp);
114     if(empty_list(lp))                                  |~                                                           | 29 //清空
115     {                                                   |~                                                           | 30 void clear_list(p lp);                                                                                     
116         printf("参数为空无需删除\n");                   |~                                                           | 31 
117         return;                                         |~                                                           | 32 
118     }                                                   |~                                                           | 33 
119     lp->len--;                                          |~                                                           | 34 
120 }                                                       |~                                                           | 35 
121 //按位置插入                                            |~                                                           | 36 
122 void insert_pos(p lp,int n,int pos)                     |~                                                           | 37 #endif
123 {                                                       |~                                                           |~                                                                                                              
124     if(lp==0)                                           |~                                                           |~                                                                                                              
125     {                                                   |~                                                           |~                                                                                                              
126         printf("入参为空\n");                           |~                                                           |~                                                                                                              
127         return;                                         |~                                                           |~                                                                                                              
128     }                                                   |~                                                           |~                                                                                                              
129     if(full_list(lp))                                   |~                                                           |~                                                                                                              
130     {                                                   |~                                                           |~                                                                                                              
131         printf("表已满无法插入");                       |~                                                           |~                                                                                                              
132     }                                                   |~                                                           |~                                                                                                              
133     //位置合理性判断          

思维导图:

相关推荐
the3clipse18 小时前
MPC-HC 下载安装与最佳配置教程:免费开源、轻量无广告、支持 4K 硬解的 Windows 播放器
windows·播放器·安装教程·硬件加速·mpc-hc·字幕设置·lav filters
独隅18 小时前
WebStorm Windows 版 React / Next.js 实战替换指南
javascript·windows·webstorm
陈工大模型18 小时前
2026年11月最新免费解压软件横评:7-Zip 、 Win解压缩名列前茅
windows·软件工程·7-zip·压缩软件
中二骚年2 天前
Windows 安全中心 / 防火墙故障,calc和Microsoft Store,终端(管理员)无法正常打开。 原因 + 修复方案
windows·安全·microsoft
万联WANFLOW2 天前
CVE-2026-98432 等漏洞自查:AI 查出的 Linux、Windows 漏洞,运维怎么确认受不受影响
linux·运维·windows·网络安全
AlanAshley2 天前
Windows 中导致延迟的软硬件及协议比重
windows
yuezhilangniao2 天前
win10中文 以及 PowerShell 开发日常
windows·powershell
共享家95273 天前
408 操作系统第一章
服务器·数据库·windows
Sakura_j_h_3 天前
GitHub Actions 打包 Windows exe:中文编码与产物上传
windows·ci/cd·打包发布·github·pyinstaller·github actions
xixiaoyunya3 天前
搭一个浏览器即用的二进制文件分发点:目录规范与权限边界实践
网络·windows