might solved feladat 4
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user