八数码c语言代码.docx

八数码c语言代码 #in cludestdio.h #in cludestdlib.h #in cludememory.h struct no de{ int x,y; int cn tdif; int step; int f[9]; int xy[3][3]; }queue[10000]; int map[3][3]; int dir[4][2]={{-1,0},{1,0},{0,1},{0,-1}}; int hash[10000]; int zz[9]; int f1,f2; struct node sour,dest; int judge( int a[]) //用逆序数判断是否可达 { int i,j,k=O; for(i=1;i9;i++) if(a[i]) for(j=0;ji;j++) if(a[j]a[i]) k++; return k; } in t cou nt(i nt a[],i nt b[]) // 计算不一样的个数 { int i,j; for(i=j=0;i9;i++) if(a[i]!=b[i]) j++; return j; int match(struct node m) 〃判断是否和末状态匹配 { int i,j; for(i=0;i9;i++) if(m.f[i]!=zz[i])return 0; return 1; } int comp

文档评论(0)

1亿VIP精品文档

相关文档