Lunedì quiz - risposte
Risposta alla puntata numero 6
1: public bool MoveNext()
2: {
3: if (eof)
4: {
5: return false ;
6: }
7:
8: while (true )
9: {
10: if (!innerEnum.MoveNext())
11: {
12: eof = true ;
13: return false ;
14: }
15:
16: if (innerEnum.Current == 0)
17: {
18: eof = true ;
19: currentValue = 0;
20: return false ;
21: }
22:
23: if (innerEnum.Current != currentValue)
24: {
25: return true ;
26: }
27: }
28: }
29:
Risposta alla puntata numero 5
Risposta alla puntata numero 4
Risposta al terzo appuntamento
1: class Node
2: {
3: int X;
4: int Y;
5: Node Left;
6: Node Right;
7:
8:
9: public static void Find(Node root,
10: Node reference)
11: {
12: if (root == null )
13: {
14: return ;
15: }
16:
17: if (root.X > reference.X)
18: {
19: Find(root.Left, reference);
20: if (root.Y > reference.Y)
21: {
22: Console .WriteLine("node found" );
23: }
24: }
25:
26: Find(root.Right, reference);
27: }
28: }
29:
Risposta al lunedì quiz – 2
Molto meno elaborata della precedente.
1: class foo
2: {
3: int finddupe(int [] values)
4: {
5: while (true )
6: {
7: int newIndex = values[0];
8: if (values[newIndex] == newIndex)
9: {
10: return newIndex;
11: }
12: values[0] = values[newIndex];
13: values[newIndex] = newIndex;
14: }
15: }
16: }
Risposta al lunedì quiz – 1
In allegato - clicca qui!
-quack