#include<stdio.h> #include<stdlib.h> #define maxlength 30 typedef int elemtype; typedef struct { elemtype list[maxlength]; int length;}seqlist; void InitList(seqlist *L) {    L->length=0; } void Insertlist(seqlist *L,int i,elemtype x) {    int j,n=L->length;    if(i<1||i>n)    {  printf("\n i值不合法");       exit(1);    }    if(n>=maxlength)    {  printf("\n 表空间上溢");       exit(1);    }    for(j=n-1;j<i;j--)    {        L->list[j-1]=L->list[j];    }    L->list[j]=x;    L->length++; } void DeleteList(seqlist *L,int i) {    int j,n=L->length;    if(i<1||i>n)    {       printf("\n i值不合法");       exit(1);    }    for(j=i;j<=n-1;j++)       L->list[j-1]=L->list[j];    L->length--; } int main() {    int i;    seqlist *L;    InitList(L);        for(i=1;i<31;i++)        {            Insertlist(L,i,i);        }        for(i=0;i<30;i++)            pri printf("%d",L->list[i]);        return 0; }

  • 西西    2020-05-18 10:50:56
  • 阅读 1740    收藏 0    回答 1
  • 邀请
  • 收藏
  • 分享
发送
登录 后发表评论
  • 51testing软件测试圈微信