📄 sqlist.h
字号:
#include "stdio.h"
#include "malloc.h"
#define null 0
#define maxsize 1024
typedef char datatype;
typedef struct
{ datatype data[maxsize];
int last;
}sequenlist;
int insert (sequenlist*L,datatype x,int i)
{ int j;
if (L->last==maxsize-1)
{ printf ("overflow");
return 0;
}
else if ((i<0)||(i<L->last))
{
printf ("error,please input the right 'i'");
return 0;
}
else
{
for(j=L->last;j>=i;j--)
L->data[j+1]=L->data[j];
L->data[i]=x;
L->last=L->last+1;
}
return(1);
}
int dellist(sequenlist*L,int i)
{ if ((i<0)||(i>L->last))
{
printf ("error,please input the right i");
return 0;
}
else
{
for(;i<L->last;i++)
L->data[i]=L->data[i+1];
L->last=L->last-1;
return(1);
}
}
void creatlist(sequenlist *L)
{
int n,i;
char tmp;
printf ("请输入数据的个数:\n");
scanf ("%d",&n);
for (i=0;i<n;i++)
{
printf ("data[%d]=",i);
fflush(stdin);
scanf("%c",&tmp);
L->data[i]=tmp;
}
L->last=n-1;
printf ("\n");
}
void printout (sequenlist *L)
{
int i;
for (i=0;i<=L->last;i++)
{
printf ("data[%d]=",i);
printf("%c\n",L->data[i]);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -