나는이 link에서 찾을 수 있습니다 재귀 알고리즘을 구현했습니다. 3d 배열이 10x10x10 일 때 아주 잘 작동합니다. 나는 그것이 그러나 200x200x200 배열에 대해 실행되도록하기 위해 노력하고있어Visual Studio에서 'System.StackOverflowException'을 무시하도록 강제하는 방법은 무엇입니까?
은 Visual Studio에서 내가 무한 resursive (나는 내 음식물은 OK입니다 확신) ussing 될 수 있다고 말한다. 그걸 처리 할 방법이 있습니까? 재귀 메서드 바로 앞에 [DebuggerNonUserCode]
을 넣으려고했지만 시도하지 않았습니다.
이 얘기를 깜빡 했네요, 그것은 비주얼 스튜디오에게있어 2010 년
여기 내 프로그램에서 재귀 함수가 있습니다. 나는 Unvisited로 표시된 모든 셀에 대해 실행 중입니다.
public static int tmp_lowest_floor = 0;
public static int tmp_maks_size = 0;
static void function1(Point[, ,] array, int pos_y, int pos_z, int pos_x) // recursive function
{
Point cell = array[pos_y, pos_z, pos_x];
if (cell.Visited == false && cell.IsCave)
{
cell.Visited = true; // changing to visited so we do not count anything for this cell anymore
tmp_maks_size++; // increasing for each cell in this cave (in this run)
if (tmp_lowest_floor < pos_y) { tmp_lowest_floor = pos_y; }
cell.FillNeighbourList(array, pos_y, pos_z, pos_x);// adds neighbours into cell's list (max 6) up, down, north, east, south, west
foreach (Point p in cell.neighbours) // max 6 times recursion in here (I know it sounds horrible, but once I check all the neighbours for a cell, I'll not have to check it ever again)
{
if (p != null)
{
if (p.IsCave == true && p.Visited == false)
{
function1(tablica, p.pos_y, p.pos_z, p.pos_x);
}
}
}
}
}
p.s. 반복적으로 할 수 있다는 것을 알고 있지만, 숙제는 재귀를 통해 완료해야한다고 말합니다.
당신은있는 StackOverflowException을 무시할 수 없습니다. 알고리즘을 비 재귀 적으로 구현하십시오. –
StackOverflow는 오류가 아니라 경고입니다. 당신은 무시할 수 없습니다. – SLaks
당신은 이것을 무시할 수 없을뿐만 아니라 지금까지해야합니다. – MyCodeSucks