might solved feladat 4

This commit is contained in:
szabomarton
2025-03-14 09:18:00 +01:00
parent 125039f7af
commit 4287c44e6e
49 changed files with 256 additions and 31 deletions

View File

@@ -47,5 +47,22 @@ namespace Program
infected.PrintInfectionTreeWithDepth(maxDepth, currentDepth + 1, indent + " ");
}
}
public int CountInfectedInDepthRange(int minDepth, int maxDepth, int currentDepth = 0)
{
int count = 0;
if (currentDepth >= minDepth && currentDepth <= maxDepth)
{
count++;
}
foreach (var infected in Infected)
{
count += infected.CountInfectedInDepthRange(minDepth, maxDepth, currentDepth + 1);
}
return count;
}
}
}