#include<stdio.h> #include<math.h> // #define 定义一个标识符来表示一个常量 #define OK 1 #
define ERROR -1 #define MAX_SIZE 100 // typedef 关键字来定义自己习惯的数据类型名称 typedef int
Status; typedef int ElemType ; // struct 结构体 typedef struct sqlist{ // 定义一个数组
ElemType Elem_array[MAX_SIZE] ; // 数组的长度 int length ; } SqList ; //
删除元素,传参:结构体指针,删除第几个数 ElemType Delete_SqList(SqList *L,int i){ int k ; ElemType x
; if (L->length==0){ printf("线性表L为空!\n"); return ERROR; } else if ( i<1||i>L->
length) { printf("要删除的数据元素不存在!\n") ; return ERROR ; } else{ x=L->Elem_array[i-1]
; /*保存结点的值*/ for ( k=i ; k<L->length ; k++) L->Elem_array[k-1]=L->Elem_array[k];
/* i位置以后的所有结点前移 */ L->length--; return L; } }

技术
今日推荐
PPT
阅读数 126
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信