-
大小: 432KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-11
- 語言: 其他
- 標簽: 數(shù)據(jù)結(jié)構(gòu)??課設(shè)??
資源簡介
數(shù)據(jù)結(jié)構(gòu)課設(shè)——教學計劃編制問題。歡迎下載。

代碼片段和文件信息
#include?“stdafx.h“
#include?“header.h“
#include
#include
#include
#include
Status?ListInsert(linkList?&Lint?iElemType?e)
{?//插入弧結(jié)點?e弧信息?i插入位置
int?j=1;
linkList?sp=L;//p指向第一個結(jié)點?
if(i<1)
return?ERROR;
s=(linkList)malloc(sizeof(LNode));
s->data=e;
if(i==1)//插入表頭
{
s->nextarc=L;
L=s;
}
else
{?
while(p&&j {?
j++;
p=p->nextarc;
}
if(!p)
return?ERROR;
s->nextarc=p->nextarc;
p->nextarc=s;
}
return?OK;
}
int?LocateElem(linkList?LElemType?eStatus(*compare)(ElemTypeElemType))
{//返回相應(yīng)弧結(jié)點的i位置
int?i=0;
linkList?p=L->nextarc;//p指向第一個結(jié)點
while(p)
{?
i++;
if(compare(p->datae))
return?i;
p=p->nextarc;
}
return?0;
}
Status?ListDelete(linkList?Lint?iElemType?&e)
{//把第i個弧結(jié)點賦給e然后刪除之?
int?j=0;
linkList?qp=L;
while(p->nextarc&&j {?
j++;
p=p->nextarc;
}
if(!p->nextarc||j>i-1)
return?ERROR;
q=p->nextarc;//q指向待刪除結(jié)點
p->nextarc=q->nextarc;
e=q->data;
free(q);
return?OK;
}
void?Input(VertexType?&ver)
{//輸入弧結(jié)點的值
scanf(“%s“&ver.name);
}
void?visit(VertexType?ver)
{?//打印弧結(jié)點的值
printf(“%s“ver.name);
}
void?InputScore(VertexType?&ver)
{//輸入學分?
scanf(“%d“&ver.score);
}
void?visitScore(VertexType?ver)
{//輸出學分
printf(“%d“ver.score);
}
void?InputArc(InfoType?*&arc)//輸入弧的相關(guān)信息
{?
arc=(InfoType?*)malloc(sizeof(InfoType));//動態(tài)生成存放弧的信息空間
scanf(“%d“&arc->weight);
}
void?OutputArc(InfoType?*arc)
{?//打印弧的相關(guān)信息
printf(“%s\n“arc);
}
int?LocateVex(ALGraph?GVertexType?u)
{?//返回頂點在圖中的位置
int?i;
for(i=0;i if(strcmp(u.nameG.vertices[i].data.name)==0)//頂點與給定的u頂點相同
return?i;
return?0;
}
VertexType?GetVex(ALGraph?Gint?v)
{//返回頂點V的值
if(v>=G.vexnum||v<0)
exit(OVERFLOW);
return?G.vertices[v].data;
}
void?InsertVex(ALGraph?&GVertexType?v)
{?//在圖中加入新的結(jié)點
G.vertices[G.vexnum].data=v;
G.vertices[G.vexnum].firstarc=NULL;
G.vexnum++;
}
Status?InsertArc(ALGraph?&GVertexType?vVertexType?w)
{??//在圖中加入弧
ElemType?e;//表結(jié)點的元素類型
int?ij;
//char?s1[3]=“邊“s2[3]=“-“;
char?s1[4]=“邊“s2[3]=“-“;
if(G.kind<2)//有向
{
strcpy(s1“弧“);
strcpy(s2“->“);
}
i=LocateVex(Gv);
j=LocateVex(Gw);
if(i<0||j<0)
return?ERROR;
G.arcnum++;//圖G的弧或邊的數(shù)目加1
e.adjvex=j;//弧頭表結(jié)點的值
e.info=NULL;
if(G.kind%2)
{?
printf(“請輸入%s%s%s%s的信息:“s1v.names2w.name);
InputArc(e.info);
}
ListInsert(G.vertices[i].firstarc1e);
if(G.kind>=2)//無向,生成另一個結(jié)點
{?
e.adjvex=i;//弧表尾結(jié)點的值
ListInsert(G.vertices[j].firstarc1e);
}
return?OK;
}
void?CreateGraph(ALGraph?&G)
{?//采用鄰接表構(gòu)一個圖
int?ijkmn;
VertexType?v1v2;//頂點類型
ElemType?e;
char?s1[4]?=““;
char?s2[]?=?“000“;
printf(“*********************************************“);
printf(“\n請輸入所有的課程數(shù)量:“);
scanf(“%d“&G.vexnum);
//printf(“請輸入有幾個先后關(guān)系:“);
//scanf(“%d“&G.arcnum);
G.arcnum?=?0;
printf(“請輸入第%d個課程的信息:
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????326824??2011-12-20?20:56??3109006503莊文弘?設(shè)計11\設(shè)計\3109006503莊文弘?設(shè)計.docx
?????文件??????13379??2011-07-06?09:32??3109006503莊文弘?設(shè)計11\設(shè)計\graph.cpp
?????文件???????5160??2011-07-06?01:35??3109006503莊文弘?設(shè)計11\設(shè)計\header.h
?????文件???????1339??2011-07-04?22:26??3109006503莊文弘?設(shè)計11\設(shè)計\queue.cpp
?????文件????????155??2011-12-20?20:57??3109006503莊文弘?設(shè)計11\設(shè)計\readme.txt
?????文件???????2009??2011-07-05?17:46??3109006503莊文弘?設(shè)計11\設(shè)計\stack.cpp
?????文件????????301??2011-07-02?11:09??3109006503莊文弘?設(shè)計11\設(shè)計\stdafx.cpp
?????文件????????320??2011-07-02?11:09??3109006503莊文弘?設(shè)計11\設(shè)計\stdafx.h
?????文件???????6027??2011-07-06?09:38??3109006503莊文弘?設(shè)計11\設(shè)計\timeableSystem.cpp
?????文件?????477696??2011-07-06?09:35??3109006503莊文弘?設(shè)計11\設(shè)計\timeableSystem.exe
?????目錄??????????0??2011-12-20?20:57??3109006503莊文弘?設(shè)計11\設(shè)計
?????目錄??????????0??2011-12-20?20:51??3109006503莊文弘?設(shè)計11
-----------?---------??----------?-----??----
???????????????833210????????????????????12
評論
共有 條評論