#include <stdio.h>
#include <stdlib.h>
typedef struct ArcNode{
int x; // 表示与当前顶点所表示省份相邻的省份的位置信息
struct ArcNode *next;
}ArcNode; // 表示省份之间相邻关系的弧结点
typedef struct{
char *name; // 顶点所表示的省份的名称
int color;
ArcNode *firstnext; // 指向第一个弧
}Province[35];
int main()
{
Province province;
int i,j;
ArcNode
*p,*hu1,*hu2,*hu3,*hu4,*hu5,*hu6,*hu7,*hu8,*hu9,*hu10,*hu11,*hu12,*hu13,*hu14,*hu15,*hu16,*hu17,*hu18;
ArcNode *hu19,*hu20,*hu21,*hu22,*hu23,*hu24,*hu25,*hu26,*hu27,*hu28,*hu29,*hu30,*hu31,*hu32,*hu33,*hu34,*hu35;
ArcNode *hu36,*hu37,*hu38,*hu39,*hu40,*hu41,*hu42,*hu43,*hu44,*hu45,*hu46,*hu47,*hu48,*hu49,*hu50,*hu51,*hu52;
ArcNode *hu53,*hu54,*hu55,*hu56,*hu57,*hu58,*hu59,*hu60,*hu61,*hu62,*hu63,*hu64,*hu65,*hu66;
ArcNode *hu67,*hu68,*hu69,*hu70,*hu71,*hu72,*hu73,*hu74,*hu75,*hu76,*hu77,*hu78,*hu79,*hu80,*hu81,*hu82,*hu83,*hu84;
ArcNode *hu85,*hu86,*hu87,*hu88,*hu89,*hu90,*hu91,*hu92,*hu93,*hu94,*hu95,*hu96,*hu97,*hu98,*hu99,*hu100;
ArcNode *hu101,*hu102,*hu103,*hu104,*hu105,*hu106,*hu107,*hu108,*hu109,*hu110,*hu111,*hu112,*hu113,*hu114,*hu115,*hu116,*hu117;
ArcNode *hu118,*hu119,*hu120,*hu121,*hu122,*hu123,*hu124,*hu125,*hu126,*hu127,*hu128,*hu129;
ArcNode *hu130,*hu131,*hu132,*hu133,*hu134,*hu135,*hu136,*hu137,*hu138,*hu139,*hu140,*hu141,*hu142,*hu143,*hu144;//声明表示省份顶点的信息
hu1=(ArcNode *)malloc(sizeof(ArcNode));
hu2=(ArcNode *)malloc(sizeof(ArcNode));
hu3=(ArcNode *)malloc(sizeof(ArcNode));
hu4=(ArcNode *)malloc(sizeof(ArcNode));
hu5=(ArcNode *)malloc(sizeof(ArcNode));
hu6=(ArcNode *)malloc(sizeof(ArcNode));
hu7=(ArcNode *)malloc(sizeof(ArcNode));
hu8=(ArcNode *)malloc(sizeof(ArcNode));
hu9=(ArcNode *)malloc(sizeof(ArcNode));
hu10=(ArcNode *)malloc(sizeof(ArcNode));
hu11=(ArcNode *)malloc(sizeof(ArcNode));
hu12=(ArcNode *)malloc(sizeof(ArcNode));
hu13=(ArcNode *)malloc(sizeof(ArcNode));
hu14=(ArcNode *)malloc(sizeof(ArcNode));
hu15=(ArcNode *)malloc(sizeof(ArcNode));
hu16=(ArcNode *)malloc(sizeof(ArcNode));
hu17=(ArcNode *)malloc(sizeof(ArcNode));
hu18=(ArcNode *)malloc(sizeof(ArcNode));
hu19=(ArcNode *)malloc(sizeof(ArcNode));
hu20=(ArcNode *)malloc(sizeof(ArcNode));
hu21=(ArcNode *)malloc(sizeof(ArcNode));
hu22=(ArcNode *)malloc(sizeof(ArcNode));
hu23=(ArcNode *)malloc(sizeof(ArcNode));
hu24=(ArcNode *)malloc(sizeof(ArcNode));
hu25=(ArcNode *)malloc(sizeof(ArcNode));
hu26=(ArcNode *)malloc(sizeof(ArcNode));
hu27=(ArcNode *)malloc(sizeof(ArcNode));
hu28=(ArcNode *)malloc(sizeof(ArcNode));
hu29=(ArcNode *)malloc(sizeof(ArcNode));
hu30=(ArcNode *)malloc(sizeof(ArcNode));
hu31=(ArcNode *)malloc(sizeof(ArcNode));
hu32=(ArcNode *)malloc(sizeof(ArcNode));
hu33=(ArcNode *)malloc(sizeof(ArcNode));
hu34=(ArcNode *)malloc(sizeof(ArcNode));
hu35=(ArcNode *)malloc(sizeof(ArcNode));
hu36=(ArcNode *)malloc(sizeof(ArcNode));
hu37=(ArcNode *)malloc(sizeof(ArcNode));
hu38=(ArcNode *)malloc(sizeof(ArcNode));
hu39=(ArcNode *)malloc(sizeof(ArcNode));
hu40=(ArcNode *)malloc(sizeof(ArcNode));
hu41=(ArcNode *)malloc(sizeof(ArcNode));
hu42=(ArcNode *)malloc(sizeof(ArcNode));
hu43=(ArcNode *)malloc(sizeof(ArcNode));
hu44=(ArcNode *)malloc(sizeof(ArcNode));
hu45=(ArcNode *)malloc(sizeof(ArcNode));
hu46=(ArcNode *)malloc(sizeof(ArcNode));
hu47=(ArcNode *)malloc(sizeof(ArcNode));
hu48=(ArcNode *)malloc(sizeof(ArcNode));
hu49=(ArcNode *)malloc(sizeof(ArcNode));
hu50=(ArcNode *)malloc(sizeof(ArcNode));
hu51=(ArcNode *)malloc(sizeof(ArcNode));
hu52=(ArcNode *)malloc(sizeof(ArcNode));
hu53=(ArcNode *)malloc(sizeof(ArcNode));
hu54=(ArcNode *)malloc(sizeof(ArcNode));
hu55=(ArcNode *)malloc(sizeof(ArcNode));
hu56=(ArcNode *)malloc(sizeof(ArcNode));
hu57=(ArcNode *)malloc(sizeof(ArcNode));
hu58=(ArcNode *)malloc(sizeof(ArcNode));
hu59=(ArcNode *)malloc(sizeof(ArcNode));
hu60=(ArcNode *)malloc(sizeof(ArcNode));
hu61=(ArcNode *)malloc(sizeof(ArcNode));
hu62=(ArcNode *)malloc(sizeof(ArcNode));
hu63=(ArcNode *)malloc(sizeof(ArcNode));
hu64=(ArcNode *)malloc(sizeof(ArcNode));
hu65=(ArcNode *)malloc(sizeof(ArcNode));
hu66=(ArcNode *)malloc(sizeof(ArcNode));
hu67=(ArcNode *)malloc(sizeof(ArcNode));
hu68=(ArcNode *)malloc(sizeof(ArcNode));
hu69=(ArcNode *)malloc(sizeof(ArcNode));
hu70=(ArcNode *)malloc(sizeof(ArcNode));
hu71=(ArcNode *)malloc(sizeof(ArcNode));
hu72=(ArcNode *)malloc(sizeof(ArcNode));
hu73=(ArcNode *)malloc(sizeof(ArcNode));
hu74=(ArcNode *)malloc(sizeof(ArcNode));
hu75=(ArcNode *)malloc(sizeof(ArcNode));
hu76=(ArcNode *)malloc(sizeof(ArcNode));
hu77=(ArcNode *)malloc(sizeof(ArcNode));
hu78=(ArcNode *)malloc(sizeof(ArcNode));
hu79=(ArcNode *)malloc(sizeof(ArcNode));
hu80=(ArcNode *)malloc(sizeof(ArcNode));
hu81=(ArcNode *)malloc(sizeof(ArcNode));
hu82=(ArcNode *)malloc(sizeof(ArcNode));
hu83=(ArcNode *)malloc(sizeof(ArcNode));
hu84=(ArcNode *)malloc(sizeof(ArcNode));
hu85=(ArcNode *)malloc(sizeof(ArcNode));
hu86=(ArcNode *)malloc(sizeof(ArcNode));
hu87=(ArcNode *)malloc(sizeof(ArcNode));
hu88=(ArcNode *)malloc(sizeof(ArcNode));
hu89=(ArcNode *)malloc(sizeof(ArcNode));
hu90=(ArcNode *)malloc(sizeof(ArcNode));
hu91=(ArcNode *)malloc(sizeof(ArcNode));
hu92=(ArcNode *)malloc(sizeof(ArcNode));
hu93=(ArcNode *)malloc(sizeof(ArcNode));
hu94=(ArcNode *)malloc(sizeof(ArcNode));
hu95=(ArcNode *)malloc(sizeof(ArcNode));
hu96=(ArcNode *)malloc(sizeof(ArcNode));
hu97=(ArcNode *)malloc(sizeof(ArcNode));
hu98=(ArcNode *)malloc(sizeof(ArcNode));
hu99=(ArcNode *)malloc(sizeof(ArcNode));
hu100=(ArcNode *)malloc(sizeof(ArcNode));
hu101=(ArcNode *)malloc(sizeof(ArcNode));
hu102=(ArcNode *)malloc(sizeof(ArcNode));
hu103=(ArcNode *)malloc(sizeof(ArcNode));
hu104=(ArcNode *)malloc(sizeof(ArcNode));
hu105=(ArcNode *)malloc(sizeof(ArcNode));
hu106=(ArcNode *)malloc(sizeof(ArcNode));
hu107=(ArcNode *)malloc(sizeof(ArcNode));
hu108=(ArcNode *)malloc(sizeof(ArcNode));
hu109=(ArcNode *)malloc(sizeof(ArcNode));
hu110=(ArcNode *)malloc(sizeof(ArcNode));
hu111=(ArcNode *)malloc(sizeof(ArcNode));
hu112=(ArcNode *)malloc(sizeof(ArcNode));
hu113=(ArcNode *)malloc(sizeof(ArcNode));
hu114=(ArcNode *)malloc(sizeof(ArcNode));
hu115=(ArcNode *)malloc(sizeof(ArcNode));
hu116=(ArcNode *)malloc(sizeof(ArcNode));
hu117=(ArcNode *)malloc(sizeof(ArcNode));
hu118=(ArcNode *)malloc(sizeof(ArcNode));
hu119=(ArcNode *)malloc(sizeof(ArcNode));
hu120=(ArcNode *)malloc(sizeof(ArcNode));
hu121=(ArcNode *)malloc(sizeof(ArcNode));
hu122=(ArcNode *)malloc(sizeof(ArcNode));
hu123=(ArcNode *)malloc(sizeof(ArcNode));
hu124=(ArcNode *)malloc(sizeof(ArcNode));
hu125=(ArcNode *)malloc(sizeof(ArcNode));
hu126=(ArcNode *)malloc(sizeof(ArcNode));
hu127=(ArcNode *)malloc(sizeof(ArcNode));
hu128=(ArcNode *)malloc(sizeof(ArcNode));
hu129=(ArcNode *)malloc(sizeof(ArcNode));
hu130=(ArcNode *)malloc(sizeof(ArcNode));
hu131=(ArcNode *)malloc(sizeof(ArcNode));
hu132=(ArcNode *)malloc(sizeof(ArcNode));
hu133=(ArcNode *)malloc(sizeof(ArcNode));
hu134=(ArcNode *)malloc(sizeof(ArcNode));
hu135=(ArcNode *)malloc(sizeof(ArcNode));
hu136=(ArcNode *)malloc(sizeof(ArcNode));
hu137=(ArcNode *)malloc(sizeof(ArcNode));
hu138=(ArcNode *)malloc(sizeof(ArcNode));
hu139=(ArcNode *)malloc(sizeof(ArcNode));
hu140=(ArcNode *)malloc(sizeof(ArcNode));
hu141=(ArcNode *)malloc(sizeof(ArcNode));
hu142=(ArcNode *)malloc(sizeof(ArcNode));
hu143=(ArcNode *)malloc(sizeof(ArcNode));
hu144=(ArcNode *)malloc(sizeof(ArcNode));
province[1].name="黑龙江";
hu1->x=2;
hu2->x=4;
province[1].firstnext=hu1;//声名表示省份之间相邻的弧
hu1->next=hu2;
hu2->next=NULL;
province[2].name="吉林";
hu3->x=4;
hu4->x=3;
hu141->x=1;
province[2].firstnext=hu3;
hu3->next=hu4;
hu4->next=hu141;
hu141->next=NULL;
province[3].name="辽宁";
hu5->x=4;
hu6->x=10;
hu142->x=2;
province[3].firstnext=hu5;
hu5->next=hu6;
hu6->next=hu142;
hu142->next=NULL;
province[4].name="内蒙古";
hu7->x=1;
hu8->x=2;
hu9->x=3;
hu10->x=10;
hu11->x=9;
hu12->x=8;
hu13->x=7;
hu14->x=6;
hu15->x=5;
province[4].firstnext=hu7;
hu7->next=hu8;
hu8->next=hu9;
hu9->next=hu10;
hu10->next=hu11;
hu11->next=hu12;
hu12->next=hu13;
hu13->next=hu14;
hu14->next=hu15;
hu15->next=NULL;
province[5].name="新疆";
hu16->x=6;
hu17->x=13;
hu18->x=16;
province[5].firstnext=hu16;
hu16->next=hu17;
hu17->next=hu18;
hu18->next=NULL;
province[6].name="甘肃";
hu19->x=4;
hu20->x=7;
hu21->x=8;
hu22->x=17;
hu23->x=13;
hu24->x=5;
province[6].firstnext=hu19;
hu19->next=hu20;
hu20->next=hu21;
hu21->next=hu22;
hu22->next=hu23;
hu23->next=hu24;
hu24->next=NULL;
province[7].name="宁夏";
hu25->x=4;
hu26->x=8;
hu27->x=6;
province[7].firstnext=hu25;
hu25->next=hu26;
hu26->next=hu27;
hu27->next=NULL;
province[8].name="陕西";
hu28->x=4;
hu29->x=9;
hu30->x=14;
hu31->x=19;
hu32->x=18;
hu33->x=17;
hu34->x=6;
hu35->x=7;
province[8].firstnext=hu28;
hu28->next=hu29;
hu29->next=hu30;
hu30->next=hu31;
hu31->next=hu32;
hu32->next=hu33;
hu33->next=hu34;
hu34->next=hu35;
hu35->next=NULL;
province[9].name="山西";
hu36->x=4;
hu37->x=10;
hu38->x=14;
hu39->x=8;
province[9].firstnext=hu36;
hu36->next=hu37;
hu37->next=hu38;
hu38->next=hu39;
hu39->next=NULL;
province[10].name="河北";
hu40->x=4;
hu41->x=3;
hu42->x=11;
hu43->x=12;
hu44->x=15;
hu45->x=14;
hu46->x=9;
province[10].firstnext=hu40;
hu40->next=hu41;
hu41->next=hu42;
hu42->next=hu43;
hu43->next=hu44;
hu44->next=hu45;
hu45->next=hu46;
hu46->next=NULL;
province[11].name="北京";
hu47->x=10;
hu48->x=12;
province[11].firstnext=hu47;
hu47->next=hu48;
hu48->next=NULL;
province[12].name="天津";
hu49->x=10;
hu50->x=11;
province[12].firstnext=hu49;
hu49->next=hu50;
hu50->next=NULL;
province[13].name="青海";
hu51->x=5;
hu52->x=6;
hu53->x=17;
hu54->x=16;
province[13].firstnext=hu51;
hu51->next=hu52;
hu52->next=hu53;
hu53->next=hu54;
hu54->next=NULL;
province[14].name="河南";
hu55->x=9;
hu56->x=10;
hu57->x=15;
hu58->x=21;
hu59->x=20;
hu60->x=19;
hu61->x=8;
province[14].firstnext=hu55;
hu55->next=hu56;
hu56->next=hu57;
hu57->next=hu58;
hu58->next=hu59;
hu59->next=hu60;
hu60->next=hu61;
hu61->next=NULL;
province[15].name="山东";
hu62->x=10;
hu63->x=14;
hu64->x=21;
province[15].firstnext=hu62;
hu62->next=hu63;
hu63->next=hu64;
hu64->next=NULL;
province[16].name="西藏";
hu65->x=5;
hu66->x=13;
hu67->x=17;
hu68->x=23;
province[16].firstnext=hu65;
hu65->next=hu66;
hu66->next=hu67;
hu67->next=hu68;
hu68->next=NULL;
province[17].name="四川";
hu69->x=13;
hu70->x=6;
hu71->x=8;
hu72->x=18;
hu73->x=24;
hu74->x=23;
hu75->x=16;
province[17].firstnext=hu69;
hu69->next=hu70;
hu70->next=hu71;
hu71->next=hu72;
hu72->next=hu73;
hu73->next=hu74;
hu74->next=hu75;
hu75->next=NULL;
province[18].name="重庆";
hu76->x=17;
hu77->x=8;
hu78->x=19;
hu79->x=25;
hu80->x=24;
province[18].firstnext=hu76;
hu76->next=hu77;
hu77->next=hu78;
hu78->next=hu79;
hu79->next=hu80;
hu80->next=NULL;
province[19].name="湖北";
hu81->x=8;
hu82->x=14;
hu83->x=20;
hu84->x=26;
hu85->x=25;
hu86->x=18;
province[19].firstnext=hu81;
hu81->next=hu82;
hu82->next=hu83;
hu83->next=hu84;
hu84->next=hu85;
hu85->next=hu86;
hu86->next=NULL;
province[20].name="安徽";
hu87->x=14;
hu88->x=21;
hu89->x=27;
hu90->x=26;
hu91->x=19;
province[20].firstnext=hu87;
hu87->next=hu88;
hu88->next=hu89;
hu89->next=hu90;
hu90->next=hu91;
hu91->next=NULL;
province[21].name="江苏";
hu92->x=15;
hu93->x=14;
hu94->x=20;
hu95->x=27;
hu96->x=22;
province[21].firstnext=hu92;
hu92->next=hu93;
hu93->next=hu94;
hu94->next=hu95;
hu95->next=hu96;
hu96->next=NULL;
province[22].name="上海";
hu97->x=21;
hu98->x=27;
province[22].firstnext=hu97;
hu97->next=hu98;
hu98->next=NULL;
province[23].name="云南";
hu99->x=16;
hu100->x=17;
hu101->x=24;
hu102->x=29;
province[23].firstnext=hu99;
hu99->next=hu100;
hu100->next=hu101;
hu101->next=hu102;
hu102->next=NULL;
province[24].name="贵州";
hu103->x=17;
hu104->x=24;
hu105->x=29;
hu106->x=23;
hu107->x=18;
province[24].firstnext=hu103;
hu103->next=hu104;
hu104->next=hu105;
hu105->next=hu106;
hu106->next=hu107;
hu107->next=NULL;
province[25].name="湖南";
hu108->x=18;
hu109->x=19;
hu110->x=26;
hu111->x=30;
hu112->x=29;
hu113->x=24;
province[25].firstnext=hu108;
hu108->next=hu109;
hu109->next=hu110;
hu110->next=hu111;
hu111->next=hu112;
hu112->next=hu113;
hu113->next=NULL;
province[26].name="江西";
hu114->x=25;
hu115->x=19;
hu116->x=20;
hu117->x=27;
hu118->x=28;
hu119->x=30;
province[26].firstnext=hu114;
hu114->next=hu115;
hu115->next=hu116;
hu116->next=hu117;
hu117->next=hu118;
hu118->next=hu119;
hu119->next=NULL;
province[27].name="浙江";
hu120->x=22;
hu121->x=21;
hu122->x=20;
hu123->x=26;
hu124->x=28;
province[27].firstnext=hu120;
hu120->next=hu121;
hu121->next=hu122;
hu122->next=hu123;
hu123->next=hu124;
hu124->next=NULL;
province[28].name="福建";
hu125->x=27;
hu126->x=26;
hu127->x=30;
province[28].firstnext=hu125;
hu125->next=hu126;
hu126->next=hu127;
hu127->next=NULL;
province[29].name="广西";
hu128->x=23;
hu129->x=24;
hu130->x=25;
hu131->x=30;
province[29].firstnext=hu128;
hu128->next=hu129;
hu129->next=hu130;
hu130->next=hu131;
hu131->next=NULL;
province[30].name="广东";
hu132->x=29;
hu133->x=25;
hu134->x=26;
hu135->x=28;
hu136->x=31;
hu137->x=32;
hu138->x=34;
province[30].firstnext=hu132;
hu132->next=hu133;
hu133->next=hu134;
hu134->next=hu135;
hu135->next=hu136;
hu136->next=hu137;
hu137->next=hu138;
hu138->next=NULL;
province[31].name="澳门";
hu139->x=30;
province[31].firstnext=hu139;
hu139->next=NULL;
province[32].name="香港";
hu140->x=30;
province[32].firstnext=hu140;
hu140->next=NULL;
province[33].name="台湾";
hu141->x=28;
province[33].firstnext=hu141;
hu141->next=NULL;
province[34].name="海南";
hu142->x=30;
province[34].firstnext=hu142;
hu142->next=NULL;
for(i=1;i<=34;i++)
{
province[i].color=0;
}
for(i=1;i<=34;i++)
{
j=1;
p=province[i].firstnext;
while(p!=NULL)
{
p=province[i].firstnext;
while(p!=NULL&&j!=province[p->x].color)
{
p=p->next;
}
if(p!=NULL)
j++;
}
province[i].color=j;
}//分别为各省份着色
//输出各城市颜色信息
printf("着色结果为:\n");
for(i=1;i<=34;i++)
{
printf("%s:",province[i].name);
if(province[i].color==0)
printf("%d 白色\n",province[i].color);
else if(province[i].color==1)
printf("%d 蓝色\n",province[i].color);
else if(province[i].color==2)
printf("%d 红色\n",province[i].color);
else if(province[i].color==3)
printf("%d 绿色\n",province[i].color);
else if(province[i].color==4)
printf("%d 黄色\n",province[i].color);
else
printf(" 无色");
}//输出各省份颜色信息
return 0;
}
这是地图着色问题的代码为什么结果会出错啊,求解答!