算法分析习题课第三章李承乾资料.ppt

int get_grid(grid grids[], int x,int y) { int n=0; for (int i=0; i8; i++) { int xx = x + direction[i][0] int yy = y + direction[i][1]; if (xx=0yy=0xxMyyN !visited[xx][yy]) { grids[n].x = xx; grids[n].y = yy; grids[n].count = get_count(xx, yy); n++; } } sort(grids,grids+n); return n; } bool operator (const grid a, const grid b) { return a.count b.count; } int get_count(int x, int y) { int i, xx, yy, count = 0; for (i=0; i8; i++) { xx = x + direction[i][0]; yy = y + direction[i][1]; if (xx=0yy=0xxMyyN!visited[xx][yy])

文档评论(0)

1亿VIP精品文档

相关文档