# include //注意其中的弧是利用单链表逆序建立的,输出弧是也是逆序的。 using namespace std; # define null 0 # define max 20 # define ok 1 typedef struct Arc {int adj; struct Arc *nextarc; }Arc; typedef struct V {char data; Arc *firstarc; }V; typedef struct { V ver[max]; int vexnum,arcnum; }ALGraph; int locate(ALGraph g,char v) {for(int i=0;i>g.vexnum; cout<<"图中的弧数:"<>g.arcnum; cout<<"请输入有向图中各顶点:"<>ch;; g.ver[i].data=ch; g.ver[i].firstarc=null; } for(k=0;k>v1>>v2; i=locate(g,v1); j=locate(g,v2); p=(Arc*)malloc(sizeof(Arc)); if(!p) return 0; p->adj=j; p->nextarc=g.ver[i].firstarc; g.ver[i].firstarc=p; } return ok; } int travel(ALGraph g) {Arc *p; int i; for(i=0;i"<adj].data; cout<nextarc; } } return ok; } int main() {ALGraph g; creategraPh(g); cout<<"各条弧的输出情况如下所示:"<