#include<stdio.h>
void update(int xiabiao,int b[],int xinshu);
void charu(int weizhi,int b[],
int charushu,int shuzuchang);
void shanchu(int weizhi,int b[],
int *changdu);
void shuchu(int aa[],int biaochang);
void chazhao(int aa[],int biaochang,int beizhaoshu);
void main()
{
/* 顺序存储的线性表 - 顺序表 */
int a[100]={1,2,4,5},biaochang=4,i;
int charuweizhi=2;
int shanchuweizhi=1;
printf("原始线性表\n");
shuchu(a,biaochang);
printf("线性表插入3以后\n");
charu(charuweizhi,a,3,&biaochang);//changdu=&biaochang
shuchu(a,biaochang);
printf("线性表删除下标位置%d以后\n",shanchuweizhi);
shanchu(shanchuweizhi,a,&biaochang);
shuchu(a,biaochang);
chazhao(a,biaochang,4);
chazhao(a,biaochang,10);
}
void charu(int weizhi,int b[],
int charushu,int *changdu)
{
int i;
for(i=*changdu;i>weizhi;i--)
b[i]=b[i-1];
b[weizhi]=charushu;
(*changdu)++;
}
void shanchu(int weizhi,int b[],
int *changdu)
{
int i;
for(i=weizhi;i<*changdu;i++ )
b[i]=b[i+1];
(*changdu)--;
}
void shuchu(int aa[],int biaochang)
{ int i;
for(i=0;i<biaochang;i++)
printf("aa[%d]=%d ",i,aa[i]);
printf("\n biaochang:%d \n",biaochang);
printf("\n");
}
void chazhao(int aa[],int biaochang,int beizhaoshu)
{
int i;
for(i=0;i<biaochang;i++)
if(aa[i]==beizhaoshu)
{
printf("找到了%d,位置%d\n ",beizhaoshu,i);
break;
}
if(i==biaochang)
printf("%d没有找到\n",beizhaoshu);
}
标签:biaochang,线性表,int,void,weizhi,用例,0903,changdu,2008
From: https://blog.51cto.com/emanlee/8247333