91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

鍵盤輸入數(shù)據(jù),建立一個有向圖的鄰接表,并輸出該鄰接表;在有向圖的鄰接表的基礎(chǔ)上計算各頂點的度,并輸出;以有向圖的鄰接表為基礎(chǔ)實現(xiàn)并輸出它的拓撲排序序列;

資源截圖

代碼片段和文件信息

#include
#include
struct?IkGraph
{
int?data;
struct?IkGraph?*next;
};
int?menu()
{
printf(“-------------------------------------------------------\n“);
printf(“1:鍵盤輸入數(shù)據(jù),建立一個有向圖的鄰接表,并輸出該鄰接表\n“);
printf(“2:在有向圖的鄰接表的基礎(chǔ)上計算各頂點的度,并輸出\n“);
????printf(“3:以有向圖的鄰接表為基礎(chǔ)實現(xiàn)并輸出它的拓撲排序序列\(zhòng)n“);
printf(“0:退出\n“);
????printf(“--------------------------------------------------------\n“);
printf(“請輸入要選擇的功能:“);
int?chose;
scanf(“%d“&chose);
return?chose;
}
int*?inD(IkGraph?*Lint?nint?*in)
{
IkGraph?*p;
for(int?i=0;i {
if(L[i].next!=NULL)
{
p=L[i].next;
while(p!=NULL)
{
in[p->data-1]++;
p=p->next;
}
}
}
????return?in;
}
int*?outD(IkGraph?*Lint?nint?*out)
{
IkGraph?*p;
for(int?i=0;i {
if(L[i].next!=NULL)
{
p=L[i].next;
while(p!=NULL)
{
out[L[i].data-1]++;
p=p->next;
}
}
}
????return?out;
}
void?main()
{
int?chose;
int?nij;
IkGraph?*p;
int?**node*in*out;
int?flag=0count=0top=0;
int?*stack;
struct?IkGraph?*list*tem;
loop: chose=menu();
switch(chose)
{
case?1:
????????printf(“請輸入頂點的個數(shù):“);
???????? scanf(“%d“&n);
????????????node=(int?**)malloc(n*sizeof(int?*));
???????? for(i=0;i???????????? node[i]=(int?*)malloc(n*sizeof(int));
printf(“請輸入各條邊的連通性(以0或1替代0表示不連通1表示連通):\n“);
???????? for(i=0;i???????? for(j=0;j {
if(i!=j)
{
????????????????????? printf(“%d->%d的連通性:“i+1j+1);
???????????? ????? scanf(“%d“&node[i][j]);
}
}?
????????list=(IkGraph?*)

評論

共有 條評論

相關(guān)資源