#include <stdio.h>
#define MAXSIZE100// 定义顺序表最大长度
typedef struct {
int data[MAXSIZE];// 顺序表数组
int length;// 当前顺序表长度} SqList;voiddeleteElement(SqList *L, int x){
int k =0;// 用于记录不等于 x 的元素个数for(int i =0; i <L->length; i++){if(L->data[i]!= x){L->data[k]=L->data[i];// 将不等于 x 的元素向前移动
k++;}}L->length = k;// 更新顺序表长度}
int main(){
SqList list ={{2,3,5,2,7,8,2},7};// 初始化顺序表
int x =2;// 需要删除的元素值printf("删除前的顺序表:");for(int i =0; i < list.length; i++){printf("%d ", list.data[i]);}printf("\n");deleteElement(&list, x);printf("删除后的顺序表:");for(int i =0; i < list.length; i++){printf("%d ", list.data[i]);}printf("\n");return0;}