题目是这样的:给定一个二维数组,实现一个功能函数 fn,向这个函数中传递这个二维数组的一个坐标,如果这个坐标的值为 ”1“,将返回和这个坐标所有相连的并且坐标值为1坐标。例如,传递了 fn([3,4])得到的结果为:[[3,4],[4,4],[5,4],[6,4],[7,4],[8,4],[8,5],[8,6]]var arr =[ [0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,1,0,0,0,1,0,0], [0,0,0,0,1,0,0,0,1,0,0], [0,0,0,0,1,0,0,0,1,0,0], [0,0,0,0,1,0,0,0,0,0,0], [0,0,0,0,1,0,0,0,0,0,0], [0,0,0,0,1,1,1,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0],] ;
添加回答
举报
0/150
提交
取消