问题:下图是一个15*30的二维矩阵迷宫(0 表示墙,1 表示道路),入口为左上角,出口为右下角。需要编写算法程将正确的路线上的数字改为2。
题目所示迷宫如下:
101001000111011101111111111111
111011100100010001000000000001
100010111100010011000011110011
111110100101111110000000010010
001000000001000000001111110010
111000000001111111111000000110
010000000000000000001000001100
110000000111100000111111001000
100000000100101110000001001111
100001110100101010011101001000
111001010100101011110101001111
001101010100111000000101000101
010101011100000011111101011101
011101000000000010000001010111
000111000000000011111111000101
解题代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
class Program
{
static void Main(string[] args)
{
int[,] arr = new int[15, 30]{
{
1,0,1,0,0,1,0,0,0,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1},
{
1,1,1,0,1,1,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1},
{
1,0,0,0,1,0,1,1,1,1,0,0,0,1,0,0,1,1,0,0,0,0,1,1,1,1,0,0,1,1},
{
1,1,1,1,1,0,1,0,0,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,1,0},
{
0,0,1,0,0,0