热门

最新

红包

立Flag

投票

同城

我的

发布
qq_73231117
XH.331
3 年前
trueqq_73231117

#include<stdio.h>
typedef int DataType;
#define MaxSize 1024
typedef struct
{
DataType data[MaxSize];
int Last;
}SeqList;

//添加运算
int SeqInsert(SeqList *L,DataType x,int i)
{
int j;
if((*L).Last==MaxSize-1)
{
printf("OverFlow\n");
return NULL;
}
else{
for(j=(*L).Last;j>=i-1;j--)
(*L).data[j+1]=(*L).data[j];
(*L).data[i-1]=x;
(*L).Last++;
}
return 1;
}

//删除运算
int SeqDelete(SeqList *L,int i)
{
int j;
if(i<1||i>(*L).Last+1)
{
printf("Position Error\n");
return NULL;
}
else
{
for(j=i;j<=(*L).Last+1;j++)
(*L).data[j-1]=(*L).data[j];
(*L).Last--;
}
return 1;
}

//创建线性表
void SeqCreate(SeqList *L)
{
int n,i;
printf("请输入n个数据\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("data[%d]=\n",i);
scanf("%d",&(*L).data[i]);
}
(*L).Last=n-1;
printf("\n");
}

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
十年技术大佬,带你深入刨析电商亿级系统是如何实现的…最实惠的java技术体系课程,优惠活动期,大家抓紧了!Java进阶+电商系统实战(了解秒杀场景、高峰限流、分布式架构等)https://fcworld.blog.csdn.net/category_11852648.html
立即登录