顺序表的应用-数据结构实验报告Word格式文档下载.docx

上传人:wj 文档编号:840515 上传时间:2023-04-29 格式:DOCX 页数:9 大小:60.61KB
下载 相关 举报
顺序表的应用-数据结构实验报告Word格式文档下载.docx_第1页
第1页 / 共9页
顺序表的应用-数据结构实验报告Word格式文档下载.docx_第2页
第2页 / 共9页
顺序表的应用-数据结构实验报告Word格式文档下载.docx_第3页
第3页 / 共9页
顺序表的应用-数据结构实验报告Word格式文档下载.docx_第4页
第4页 / 共9页
顺序表的应用-数据结构实验报告Word格式文档下载.docx_第5页
第5页 / 共9页
顺序表的应用-数据结构实验报告Word格式文档下载.docx_第6页
第6页 / 共9页
顺序表的应用-数据结构实验报告Word格式文档下载.docx_第7页
第7页 / 共9页
顺序表的应用-数据结构实验报告Word格式文档下载.docx_第8页
第8页 / 共9页
顺序表的应用-数据结构实验报告Word格式文档下载.docx_第9页
第9页 / 共9页
亲,该文档总共9页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

顺序表的应用-数据结构实验报告Word格式文档下载.docx

《顺序表的应用-数据结构实验报告Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《顺序表的应用-数据结构实验报告Word格式文档下载.docx(9页珍藏版)》请在冰点文库上搜索。

顺序表的应用-数据结构实验报告Word格式文档下载.docx

(3)根据姓名进行查找,返回此学生的学号和成绩

(4)根据指定的位置可返回相应的学生信息(学号,姓名,成绩)

(5)给定一个学生信息,插入到表中指定的位置

(6)删除指定位置的学生记录

(7)统计表中学生个数

四、实验设计

for(count=0;

count<

n;

count++)

{

scanf("

%s%s%d"

e.no,e.name,&

e.score);

Input(&

L,e);

}

StatusInput(SqList*L,ElemTypee)

if(!

(*L).elem)

returnERROR;

(*L).elem[(*L).length++]=e;

returnOK;

StatusPrint(SqListL)

printf("

学号姓名成绩\n"

);

intcount;

for(count=0;

L.length;

Pri(L.elem[count]);

voidPri(ElemTypee)

printf("

%8s|"

e.no);

printf("

%20s|"

e.name);

%8d\n"

e.score);

StatusLocateElem(SqListL,ElemTypee)

if(strcmp(L.elem[count].name,e.name)==0)

break;

if(count<

L.length)

{

Pri(L.elem[count]);

}

else

%s在顺序表中查不到!

\n"

StatusLocateNum(SqListL,inti)

if(i<

1||i>

L.length+1)

returnOVERFLOW;

Pri(L.elem[i-1]);

StatusListInsert(SqList*L,inti,ElemTypee)

if(i<

(*L).length+1)

if((*L).length==(*L).MaxSize)

(*L).elem=(ElemType*)realloc((*L).elem,sizeof(ElemType)*((*L).MaxSize+LISTINCREMENT));

exit(OVERFLOW);

for(count=(*L).length-1;

count>

=i-1;

count--)

(*L).elem[count+1]=(*L).elem[count];

(*L).elem[i-1]=e;

(*L).length++;

StatusListDelete(SqList*L,inti)

for(count=i;

(*L).length;

(*L).elem[count-1]=(*L).elem[count];

(*L).length--;

printf("

表中学生的个数为:

%d\n"

L.length);

(8)主函数

intmain()

SqListL;

ElemTypee;

inti,count,n,number;

InitList(&

L);

请输入学生的个数:

%d"

&

n);

请输入学号、姓名、成绩:

scanf("

Input(&

学生信息生成成功!

Pr();

while(n>

0&

&

n<

7)

switch(n)

{

case1:

Print(L);

case2:

请输入要查找的学生的姓名:

"

scanf("

%s"

LocateElem(L,e);

case3:

请输入要查找的学生的位置:

i);

LocateNum(L,i);

case4:

输入插入学生的位置、学号、姓名、成绩:

%d%s%s%d"

i,e.no,e.name,&

if(ListInsert(&

L,i,e))

printf("

插入成功!

case5:

请输入要删除的学生的位置:

if(ListDelete(&

L,i))

删除成功!

case6:

}

Pr();

if(n==7)

退出成功!

return0;

五、实验测试

2.定义一个包含学生信息(学号,姓名,成绩)的顺序表,使其具有如下功能运行界面

六、总结

附录1:

源代码

#include<

stdio.h>

stdlib.h>

string.h>

#defineLIST_INIT_SIZE100

#defineLISTINCREMENT10

#defineOK1

#defineERROR0

#defineOVERFLOW2

typedefintStatus;

typedefstruct

charno[8];

charname[20];

intscore;

}Student;

typedefStudentElemType;

ElemType*elem;

intlength;

intMaxSize;

}SqList;

StatusInitList(SqList*L)

(*L).elem=(ElemType*)malloc(sizeof(ElemType)*LIST_INIT_SIZE);

(*L).length=0;

(*L).MaxSize=LIST_INIT_SIZE;

voidPr()

\n1.输出全部的学生信息\n"

2.通过姓名查找学号和成绩\n"

3.通过位置查找学生的信息\n"

4.插入学生信息\n"

5.删除学生信息\n"

6.统计学生个数\n"

7.退出\n"

请输入要使用的功能:

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2