I wrote this code here:

private static float Calc(Node node) { var p = 0f; foreach (var n in node.Linked) p = node.Linked.Max(z => Calc(n)); return p; } 

The value of the elements of the collection is either 0 or 1, but for any input values ​​I always get 0, tell me what the problem is?

  • 2
    Your Calc function never returns 1 . - Igor
  • As far as I understand, the maximal element is selected among the arguments is written to p and returns p to the place of the call? I am wrong? - SAIBERPRO
  • Please read my first comment. "And I heed the sky shudder, And the highest flight of the angels, And the reptile of the marine underwater course, And the vines to the bottom of the vine." Pushkin - Igor
  • Place a function call? - SAIBERPRO pm
  • What do these three words mean? - Igor

0