自考实验题目Word文档格式.docx

上传人:b****5 文档编号:17280247 上传时间:2022-11-30 格式:DOCX 页数:13 大小:17.11KB
下载 相关 举报
自考实验题目Word文档格式.docx_第1页
第1页 / 共13页
自考实验题目Word文档格式.docx_第2页
第2页 / 共13页
自考实验题目Word文档格式.docx_第3页
第3页 / 共13页
自考实验题目Word文档格式.docx_第4页
第4页 / 共13页
自考实验题目Word文档格式.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

自考实验题目Word文档格式.docx

《自考实验题目Word文档格式.docx》由会员分享,可在线阅读,更多相关《自考实验题目Word文档格式.docx(13页珍藏版)》请在冰豆网上搜索。

自考实验题目Word文档格式.docx

;

cout<

endl;

}

voidPrint1(Ta[],intlength,intn){

for(intk=n;

k;

k--)

for(k=n;

//Thisisaproceduretoshowadatumtobeinsertedintothearray

voidIns_dat(Ta[],Tdatum,intn){

//inthalt;

//cin>

//system("

for(intk=n-1;

k--)

datum<

//Thisisaproceduretoshowwhichitemwillbedeleted

voidDel_dat(Ta[],intn){

//charhalt;

//system("

"

@"

//Thecodeaboveisapseudo-header**********************************************

#include<

iostream.h>

#include<

stdlib.h>

#include"

graph.h"

//ClassSeq_list

classSeq_list{

public:

voidManage();

Seq_list(Ta[],intn);

private:

voidInsert(Tdata,intn);

voidDelete(intn);

voidPrint();

Tarray[10];

intlength;

};

//Initializationprocedure

Seq_list<

T>

:

Seq_list(Ta[],intn){

length=n;

for(;

n;

){

array[n]=a[--n];

Print1(array,length,n);

//Print1called!

}

//Theproceduretomanageanarray

voidSeq_list<

Manage(){

charflag;

while

(1){

Operations:

\n\tToinsertadatum,pressi;

\n\tTodeleteadatum,pressd;

\n\tToprintthearray,pressp\n"

\tToquit,pressq\n"

cin>

flag;

if(flag=='

i'

||flag=='

I'

cout<

Theinsertionprocedureiscalled!

\n"

Tdatum;

intpst;

if(length>

9){

Thesequentiallistisfull!

}else{

cout<

Thelengthofthelistis"

length<

Inputthedatumyouwanttoinsert:

cin>

datum;

Inputitspositioninthearray:

pst;

Insert(datum,pst);

}

}elseif(flag=='

d'

D'

Inputthepositionofadatumyouwanttodeleteinthearray:

Delete(pst);

p'

P'

Print();

q'

Q'

break;

}else{

Nodefinition!

}

//Theproceduretoprintthearray

Print(){

for(inti=0;

i<

i++){

array[i]<

//Theproceduretoinsertadatuminthearray

Insert(Tdata,intn){

if(n<

1||n>

length+1){

PositionError!

}else{

Print1(array,length);

Ins_dat(array,data,n);

//Ins_datcalled!

length++;

for(inti=length-1;

i>

=n;

i--){

array[i]=array[i-1];

//cin>

Print1(array,length);

}

array[i]=data;

Ins_dat(array,data,n);

Print1(array,length);

//Theproceduretodeleteadatuminthearray

Delete(intn){

length){

Print1<

int>

(array,length);

Del_dat<

(array,n);

//Del_datcalled!

for(inti=n-1;

length-1;

i++){///newnewnewnew

array[i]=array[i+1];

Del_dat<

/////////////Del_datcalled!

}///endnewnew

length--;

Print1<

///End__Deletion

//mainfuntion

voidmain(){

inta[10]={3,5,4,1,98,3,9};

Inputcharicterstostartinitializingtheobject:

Seq_list<

seq=Seq_list<

(a,7);

seq.Manage();

5实验心得:

数据结构实验二

直接插入排序的基本操作

(1)掌握直接插入排序算法的基本思想;

(2)验证直接插入排序算法的实现方法;

(3)进一步掌握数据结构及算法的程序实现的基本方法;

array[k]<

voidShow_data(Ta[],Tdatum,intn){

voidLabel(Ta[],intn){

//顺序表类

voidSort();

//构造函数

charb;

system("

for(intk=n;

for(k=n;

b;

//打印数组

//直接插入排序——升序

Sort(){

intar=1;

while(ar<

intpst=ar;

Ttemp=0;

//输出当前数组

Show_data(array,temp,pst);

//显示临时变量

Label(array,ar);

//指示有序数组末位置

while(pst>

=1){

if(array[pst]<

array[pst-1]){

temp=array[pst];

//同上

Show_data(array,temp,pst);

Label(array,ar);

array[pst]=array[pst-1];

array[pst-1]=temp;

}pst--;

}ar++;

//显示最后数组

Label(array,ar);

//主函数

inta[10]={10,8,19,5,4,3};

(a,6);

//这里的数字为数组长度,必须与实际长度一致

seq.Sort();

seq.Print();

C语言实验题目

C语言实验一

1实验题目:

输入一个百分制成绩,要求输出其对应的成绩等级。

其中90~100分的成绩等级为’A’,80~89分为’B’,70~79分为’C’,60~69分为’D’,0~59分’E’。

掌握分支结构的基本用法,学会对C语言中主要语句的用法.

4程序代码:

stdio.h>

intmain()

{

floatscore;

chargrade;

printf(”pleaseinputthescore:

\n”);

scanf(”%f”,&

score);

if(score>

=90&

&

score<

=100)

grade=’A’;

elseif(score>

=80&

=89)

grade=’B’;

=70&

=79)

grade=’C’;

=60&

=69)

grade=’D’;

=0&

=59)

grade=’E’;

else

printf(”youhaveenteredthewronggrade!

”);

printf(”score=%.1f,grade=%c”,score,grade);

return0;

}

 

C语言实验二

对10个数排序,排序方式为升序。

掌握数组的定义赋值及使用,进一步熟悉循环语句的使用方法.

3设计思想:

4程序代码

inta[11];

inti,j,t;

printf(”Input10numbers:

for(i=1;

i<

=10;

i++)

scanf(”%d”,&

a[i]);

printf(”\n”);

for(j=1;

j<

=9;

j++)

=10-j;

if(a[i]>

a[i+1])

{

t=a[i];

a[i]=a[i+1];

a[i+1]=t;

printf(”Thesortednumbers:

printf(”%5d”,a[i]);

return0;

5实验心得:

C语言实验三

1实验题目;

求10名学生的平均成绩.

学会函数的定义格式和说明方法和调用方式.

voidmain()

floatscore[10],aver;

inti;

printf(“input10scores:

for(i=0;

10;

i++)

scanf(“%f”,&

score[i]);

}

aver=average(score);

printf(“\naveragescoreis%.2f”,aver);

floataverage(floatarray[10])

floataver,

floatsum=array[0];

for(i=1;

sum=sum+array[i];

aver=sum/10;

return(aver);

5实验心得

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

当前位置:首页 > 高中教育 > 英语

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1