q1->length=70; strcpy(q1->sno,\ p1->nextArc=q1; q2=(ArcNode*)malloc(sizeof(ArcNode)); q2->length=70; strcpy(q2->sno,\ q1->next=q2; q1=(ArcNode*)malloc(sizeof(ArcNode)); q1->length=40; strcpy(q1->sno,\ q2->next=q1; q2=(ArcNode*)malloc(sizeof(ArcNode)); q2->length=60; strcpy(q2->sno,\ q1->next=q2; q1=(ArcNode*)malloc(sizeof(ArcNode)); q1->length=70; strcpy(q1->sno,\ q2->next=q1; q1->next=NULL; p2=(VNode*)malloc(sizeof(VNode)); strcpy(p2->sc.sno,\ strcpy(p2->sc.sname,\足球场\ strcpy(p2->sc.stext,\运动\ p1->nextV=p2; q1=(ArcNode*)malloc(sizeof(ArcNode)); q1->length=20; strcpy(q1->sno,\ p2->nextArc=q1; q2=(ArcNode*)malloc(sizeof(ArcNode)); q2->length=60; strcpy(q2->sno,\ q1->next=q2; q1=(ArcNode*)malloc(sizeof(ArcNode)); q1->length=30; strcpy(q1->sno,\ q2->next=q1; q1->next=NULL; p2->nextV=NULL; } //创建图 bool Create(Graph& G) { VNode* last; VNode* p; cout<<\请输入景点个数以及道路条数\ cin>>G.vexnum>>G.arcnum; if((G.vexnum<=0)||(G.arcnum<=0)) return false; G.V=(VNode*)malloc(sizeof(VNode)); last=G.V; cout<<\请输入第1个景点的编号、名称、介绍\ cin>>last->sc.sno>>last->sc.sname>>last->sc.stext; last->nextArc=NULL; for(int i=1;i>p->sc.sno>>p->sc.sname>>p->sc.stext; p->nextArc=NULL; last->nextV=p; last=last->nextV; } last->nextV=NULL; char startSno[4]; char endSno[4]; int length; ArcNode* q=NULL; VNode* address=NULL; for(i=0;i>startSno>>endSno>>length; address=GetAddress(startSno,G); q=(ArcNode*)malloc(sizeof(ArcNode)); strcpy(q->sno,endSno); q->length=length; q->next=address->nextArc; address->nextArc=q; /*----------------无向网需正反两次-------------------*/ address=GetAddress(endSno,G); q=(ArcNode*)malloc(sizeof(ArcNode)); strcpy(q->sno,startSno); q->length=length; q->next=address->nextArc; address->nextArc=q; } return true; } //查询相关景点信息 void SearchScenery(Graph& G) { int count=0; VNode* p=G.V; char noOrName[21]; cout<<\请输入你想要查询的景点的编号或名称\ cin>>noOrName; for(int i=0;isc.sno)&&strcmp(noOrName,p->sc.sname))) { cout<<\景点编号:\ cout<<\景点名称:\ cout<<\景点介绍:\ count++; break; } else p=p->nextV; } if(!count) cout<<\查找失败!\} //增加景点信息 void AddScenery(Graph& G) { int count=0; int flag=0; char sno[4]; char sname[21]; char stext[201]; VNode* g=NULL; cout<<\请输入景点的编号:\ cin>>sno; g=G.V; while(g) { if(!strcmp(g->sc.sno,sno)) { flag++; break; } else g=g->nextV; } if(flag) { cout<<\输入的景点编号重复,请重新插入!\ return; } cout<<\请输入景点的名称:\cin>>sname; cout<<\请输入景点的介绍:\cin>>stext; cout<sc.sno,sno)) { count++; break; } else { parent=p; p=p->nextV; } } if(!count) { VNode* q; q=(VNode*)malloc(sizeof(VNode)); strcpy(q->sc.sno,sno); strcpy(q->sc.sname,sname); strcpy(q->sc.stext,stext); parent->nextV=q; q->nextV=NULL; q->nextArc=NULL; G.vexnum++;