学期授课计划编制Word下载.doc

上传人:b****2 文档编号:14566670 上传时间:2022-10-23 格式:DOC 页数:16 大小:330.50KB
下载 相关 举报
学期授课计划编制Word下载.doc_第1页
第1页 / 共16页
学期授课计划编制Word下载.doc_第2页
第2页 / 共16页
学期授课计划编制Word下载.doc_第3页
第3页 / 共16页
学期授课计划编制Word下载.doc_第4页
第4页 / 共16页
学期授课计划编制Word下载.doc_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

学期授课计划编制Word下载.doc

《学期授课计划编制Word下载.doc》由会员分享,可在线阅读,更多相关《学期授课计划编制Word下载.doc(16页珍藏版)》请在冰豆网上搜索。

学期授课计划编制Word下载.doc

3.性能需求

本程序在运行期间,为了避免在运行大量数据时不会出错,并且能够在很短的时间内将运行结果稳定输出,就需要系统达到安全性能好,可靠性高,稳定性强,处理数据迅速等特点。

三、程序实现

本程序采取数据结构模块化编程,很好的实现了实验所要求的各项功能,本程序分为三个主要模块:

主程序模块、栈模块、排序模块。

1.主程序模块

intmain(){

printf("

学期授课计划编制\n"

);

//AOV-网:

顶点表示活动,弧表示活动间优先关系的有向图;

intCONTINUE=1;

while(CONTINUE!

=0){

printf("

------------------------------------------------\n"

ALGraphf;

//图的邻接表存储;

printf("

请输入学期总数:

"

scanf("

%d"

&

term_num);

请输入每学期的学分上限:

credit_lim);

CreateGraph(f);

Display(f);

TopologicalSort(f);

\n按1继续,按0结束:

scanf("

CONTINUE);

}

return0;

}

2.栈模块

typedefenum{DG}GraphKind;

//{有向图,有向网,无向图,无向网};

typedefstructArcNode{//弧结构;

intadjvex;

//该弧所指向的顶点的位置;

structArcNode*nextarc;

//指向下一条弧的指针;

InfoType*info;

//网的权值指针;

}ArcNode;

//表结点;

typedefstruct{

VertexTypedata;

//顶点信息;

ArcNode*firstarc;

//第一个表结点的地址,指向第一条依附该顶点的弧的指针;

}VNode,AdjList[MAX_VERTEX_NUM];

AdjListvertices,vertices2;

//分别存课程名和学分;

intvexnum,arcnum;

intkind;

}ALGraph;

intLocateVex(ALGraphG,VertexTypeu){

inti;

for(i=0;

i<

G.vexnum;

++i)

if(strcmp(u,G.vertices[i].data)==0)

returni;

return-1;

StatusCreateGraph(ALGraph&

G){

inti,j,k;

VertexTypev1,v2;

//顶点信息;

ArcNode*p;

//指向第一条依附某顶点的弧的指针;

请输入教学计划的课程数:

"

scanf("

G.vexnum);

请输入课程先修关系数(弧的数目):

G.arcnum);

请输入%d个课程的代表值(如:

c01):

\n"

G.vexnum);

++i){

%s"

G.vertices[i].data);

G.vertices[i].firstarc=NULL;

}

请输入%d个课程的学分值:

(G).vexnum);

G.vertices2[i].data);

请顺序输入每条弧的弧尾和弧头(以空格作为间隔):

for(k=0;

k<

G.arcnum;

++k){

scanf("

%s%s"

v1,v2);

i=LocateVex(G,v1);

j=LocateVex(G,v2);

p=(ArcNode*)malloc(sizeof(ArcNode));

//新建一个节点;

p->

adjvex=j;

info=NULL;

nextarc=G.vertices[i].firstarc;

G.vertices[i].firstarc=p;

returnOK;

voidDisplay(ALGraphG){

switch(G.kind){

caseDG:

printf("

有向图\n"

%d个顶点:

printf("

%s"

\n%d条弧:

G.arcnum);

i++){

p=G.vertices[i].firstarc;

voidFindInDegree(ALGraphG,intindegree[]){

ArcNode*p;

i++)

indegree[i]=0;

while(p){

indegree[p->

adjvex]++;

p=p->

nextarc;

}

typedefintSElemType;

#defineSTACK_INIT_SIZE10

#defineSTACKINCREMENT2

typedefstructSqStack{

SElemType*base;

SElemType*top;

intstacksize;

}SqStack;

StatusInitStack(SqStack*S){

(*S).base=(SElemType*)malloc(STACK_INIT_SIZE*sizeof(SElemType));

if(!

(*S).base)

exit(OVERFLOW);

(*S).top=(*S).base;

(*S).stacksize=STACK_INIT_SIZE;

voidClearStack(SqStack*S){//清空栈的操作

S->

top=S->

base;

StatusStackEmpty(SqStackS){

if(S.top==S.base)

returnTRUE;

else

returnFALSE;

3.排序模块

StatusPop(SqStack*S,SElemType*e){

if((*S).top==(*S).base)

returnERROR;

*e=*--(*S).top;

StatusPush(SqStack*S,SElemTypee){

if((*S).top-(*S).base>

=(*S).stacksize){

(*S).base=(SElemType*)realloc((*S).base,((*S).stacksize+STACKINCREMENT)*sizeof(SElemType));

if(!

exit(OVERFLOW);

(*S).top=(*S).base+(*S).stacksize;

(*S).stacksize+=STACKINCREMENT;

*((*S).top)++=e;

Statuszxf(ALGraphG){

intz=0;

for(inti=0;

i<

G.vexnum;

i++){

z+=atoi(G.vertices2[i].data);

returnz;

typedefintpathone[MAX_CLASS_NUM];

typedefintpathtwo[MAX_CLASS_NUM];

StatusTopologicalSort(ALGraphG){

inti,k,count,indegree[MAX_VERTEX_NUM];

boolhas=false;

SqStackS;

pathonea;

pathtwob;

ArcNode*p;

FindInDegree(G,indegree);

InitStack(&

S);

for(i=0;

++i){

if(!

indegree[i])

Push(&

S,i);

}

count=0;

while(!

StackEmpty(S)){

Pop(&

S,&

i);

a[i]=*G.vertices[i].data;

//课程名;

b[i]=*G.vertices2[i].data;

//学分;

pr

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

当前位置:首页 > 工程科技 > 材料科学

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

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