文档介绍:实用标准文档
《数据结构》实验报告
实验序号: 2 实验项目名称:顺序表的操作
学 号 姓 名 专业、班级
实验地点 指导教师 实验时间
一、实验目的及要求
掌握线性表的顺序存Size)
{
ElemType *newbase;
newbase=(
ElemType
*)realloc(C->elem,
(C->ListSize+LISTINCREMENT)*sizeof(ElemType));
C->elem=newbase;
C->ListSize+=LISTINCREMENT;
}
else break;
}
for(i=0;i<C->length;i++)
{
C->elem[2*i]=A->elem[i];
C->elem[2*i+1]=B->elem[i];
}
for(i=0;i<C->length;i++)
printf("%d ",C->elem[i]);
}
void main()
{
ElemType i;
sqlist list1,list2,*A,*B;
A=&list1;
B=&list2;
InitList_sq(A);
InitList_sq(B);
printf(" 请输入 A 指向的 5 个整数: \n");
for(i=0;i<5;i++)
scanf("%d",&A->elem[i]);
A->length=i;
printf(" 请输入 B 指向的 5 个整数: \n");
for(i=0;i<5;i++)
scanf("%d",&B->elem[i]);
精彩文案
实用标准文档
B->length=i;
Alternate(A,B);
printf("\n");
}
2.
#include <>
#include <>
#include <>
#define LIST_INIT_SIZE 100
#define LISINCREMENT 10
#define ElemType int
#define Status int
typedef struct Sq{
ElemType *elem;
int length;
int listsize;
}SqList;
Status InitList(SqList *L)
{
L->elem=(ElemType*)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if(!L->elem)
return 0;
L->length=0;
L->listsize=LIST_INIT_SIZE;
return 1;
}
//--------------------------------------------------------- 插入