数据结构实验报告04Word文档格式.docx

上传人:b****3 文档编号:8126024 上传时间:2023-05-10 格式:DOCX 页数:17 大小:243.84KB
下载 相关 举报
数据结构实验报告04Word文档格式.docx_第1页
第1页 / 共17页
数据结构实验报告04Word文档格式.docx_第2页
第2页 / 共17页
数据结构实验报告04Word文档格式.docx_第3页
第3页 / 共17页
数据结构实验报告04Word文档格式.docx_第4页
第4页 / 共17页
数据结构实验报告04Word文档格式.docx_第5页
第5页 / 共17页
数据结构实验报告04Word文档格式.docx_第6页
第6页 / 共17页
数据结构实验报告04Word文档格式.docx_第7页
第7页 / 共17页
数据结构实验报告04Word文档格式.docx_第8页
第8页 / 共17页
数据结构实验报告04Word文档格式.docx_第9页
第9页 / 共17页
数据结构实验报告04Word文档格式.docx_第10页
第10页 / 共17页
数据结构实验报告04Word文档格式.docx_第11页
第11页 / 共17页
数据结构实验报告04Word文档格式.docx_第12页
第12页 / 共17页
数据结构实验报告04Word文档格式.docx_第13页
第13页 / 共17页
数据结构实验报告04Word文档格式.docx_第14页
第14页 / 共17页
数据结构实验报告04Word文档格式.docx_第15页
第15页 / 共17页
数据结构实验报告04Word文档格式.docx_第16页
第16页 / 共17页
数据结构实验报告04Word文档格式.docx_第17页
第17页 / 共17页
亲,该文档总共17页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

数据结构实验报告04Word文档格式.docx

《数据结构实验报告04Word文档格式.docx》由会员分享,可在线阅读,更多相关《数据结构实验报告04Word文档格式.docx(17页珍藏版)》请在冰点文库上搜索。

数据结构实验报告04Word文档格式.docx

5、实验时间:

8学时

6、该文档的文件名不要修改,存入<

学号>

<

姓名>

命名的文件夹中

7、该表中的数据只需填空,已有内容不要修改

实验结果(运行结果界面及源程序,运行结果界面放在前面):

欢迎界面

Cover界面

Menu界面

选择功能1,首先显示的是按照语文成绩排序前的成绩表

按任意键后显示具体的排序过程(其中加“[]”的数字为标准元素)

继续按任意键,显示排序完成后的成绩表

选择功能2,首先显示的是按照数学成绩排序前的成绩表

选择功能3,首先显示的是按照英语成绩排序前的成绩表

最后,选择功能0,退出程序

程序代码如下

#include<

stdlib.h>

stdio.h>

time.h>

string.h>

iostream.h>

#defineMaxsize100//顺序表的最大长度

intnum=0;

intflag[10];

typedeffloatKeyType;

//定义关键字类型为整型

charre_choose[]={"

\n\t\t\t您的选择非法,请输入正确的编号!

\n\n"

};

typedefstruct

{

intNo;

floatChinese;

floatMath;

floatEnglish;

floatTotal;

}Student;

Studentstudent[Maxsize];

intrecord_num;

typedefStudentEType;

typedefstruct

KeyTypekey;

//关键字项

ETypeelem;

//其它数据项

}Record;

//记录类型

Recordr[Maxsize+1];

intLength;

//顺序表长度

}SqList;

//顺序表类型

SqListL;

voidprint_Sqlist(SqList&

L)

printf("

\n第%d次排序:

\n"

num);

for(intn=0;

n<

9;

n++)

{

if(flag[n])

printf("

[%4.1f]"

L.r[n].key);

else

%4.1f"

}

);

}

intPartition(Recordr[],intlow,inthigh)

{//对记录序列L.r[low..high]进行一次快速排序,并将本范围的元素按标准元素分为两部分,且标准元素在这两部分之间。

KeyTypeStandardKey;

RecordTemp;

Temp=r[low];

//将标准记录放入中间单元

StandardKey=r[low].key;

//本范围的标准元素

while(low<

=high)//从表的两端交替地向中间扫描

{

while(low<

high&

&

r[high].key>

=StandardKey)

high--;

r[low++]=r[high];

//将小于标准元素的数据往前放

=high&

r[low].key<

low++;

r[high--]=r[low];

//将大于标准元素的数据往后放

}

r[--low]=Temp;

//标准元素移到正确位置

flag[low]=1;

print_Sqlist(L);

//打印序列排序结果

returnlow;

//返回标准位置

}

voidQsort(Recordr[],intlow,inthigh)

{//对记录序列r[low..high]进行快速排序

intStandardLoc;

if(low<

=high-1)

{

num++;

StandardLoc=Partition(r,low,high);

//对r[low..high]进行一次划分,并返回标准位置

Qsort(r,low,StandardLoc-1);

Qsort(r,StandardLoc+1,high);

voidQuickSort(SqList&

{//对顺序表L进行快速排序

Qsort(L.r,0,8);

//low和high用初值0,L.length-1调用

 

voidStudent_Reacord_Print(SqList&

┌─────┬───┬───┬───┬───┐\n│考号│语文│数学│英语│总分│\n"

for(inti=0;

i<

i++)

printf("

├─────┼───┼───┼───┼───┤\n│%d│%5.1f│%5.1f│%5.1f│%.1f│\n"

L.r[i].elem.No,L.r[i].elem.Chinese,L.r[i].elem.Math,L.r[i].elem.English,L.r[i].elem.Total);

└─────┴───┴───┴───┴───┘\n"

printf("

voidWelcome()//启动画面

{

charline[]={"

━━━━━━━━━━"

charbar[]={"

...."

inti,j,k=0,x=0,y=0;

for(i=1;

i<

=strlen(line)/2;

system("

cls"

for(j=0;

j<

j++)//改变行坐标

cout<

<

endl;

(75-strlen(line))/2;

j++)//改变列坐标

"

"

;

for(j=1;

=i;

j++)//进度显示器

■"

for(x=strlen(line)/2;

x>

i;

x--)

□"

if(k==4)

i++;

cout<

j++)//行坐标定位

line;

//输出线条

(65-strlen(bar))/2;

j++)

(i-1)*10<

%Loading"

cout.write(bar,k);

7;

24;

肖家乐·

制作\n"

中南财经政法大学信息与安全工程学院"

19;

=17;

─"

1000000;

j++);

//延时效果

k++;

if(k>

4)

k=0;

voidCover()//封面信息

\n\n\n\n\n\n"

*************************************************\n"

快速排序\n\n"

制作:

肖家乐\n"

班级:

电商1202班\n"

学号:

1209040120\n"

指导老师:

孙夫雄\n"

\n\n\n\t"

voidMenu()//菜单函数

==================================================\n\n"

请选择要执行的功能\n\n"

1.按语文成绩排序;

2.按数学成绩排序;

3.按英语成绩排序;

0.退出.\n\n"

==================================================\n"

\n\n\n\t\t"

voidSwitch(intx)//功能选择

inti;

switch(x)

case1:

system("

for(i=0;

{

L.r[i].key=student[i].Chinese;

L.r[i].elem=student[i];

}

system("

break;

case2:

{

L.r[i].key=student[i].Math;

case3:

L.r[i].key=student[i].English;

case0:

exit(0);

default:

cout<

re_choose<

pause"

system("

排序前学生成绩表为:

Student_Reacord_Print(L);

QuickSort(L);

num=0;

排序后学生成绩表为:

voidmain()

Welcome();

Cover();

floatChinese[9]={85.0,92.5,95.0,85.0,96.0,72.0,65.0,88.0,96.5};

floatMath[9]={88,91,98,87,93,76,53,94,83};

floatEnglish[9]={97.0,95.0,99.0,96.5,100.0,70.5,53.0,90.5,65.0};

floatTotal[9];

10;

Total[i]=Chinese[i]+Math[i]+English[i];

student[i].Chinese=Chinese[i];

student[i].English=English[i];

student[i].Math=Math[i];

student[i].Total=Total[i];

student[i].No=20010001+i;

while(flag)

Menu();

\n\t请输入功能编号:

intn;

cin>

>

n;

if(n<

0||n>

3)

{

continue;

Switch(n);

}

return;

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

当前位置:首页 > 小学教育 > 小学作文

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

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