回答編集履歴

2

追記

2021/01/20 15:06

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -29,3 +29,39 @@
29
29
  }
30
30
 
31
31
  ```
32
+
33
+
34
+
35
+ [追記] 別解
36
+
37
+
38
+
39
+ > int Depth(BinNode *p, int depth)という部分は指定されており、そのように作ることができません。
40
+
41
+
42
+
43
+ だったらコレ↓で:
44
+
45
+ ```C
46
+
47
+ int Depth(BinNode *p, int depth) {
48
+
49
+ if ( p == NULL ) {
50
+
51
+ return depth;
52
+
53
+ }
54
+
55
+ int depthL;
56
+
57
+ int depthR;
58
+
59
+ depthL = Depth(p->left, depth);
60
+
61
+ depthR = Depth(p->right, depth);
62
+
63
+ return (depthL>=depthR) ? depthL+1 : depthR+1;
64
+
65
+ }
66
+
67
+ ```

1

加筆

2021/01/20 15:06

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -7,3 +7,25 @@
7
7
 
8
8
 
9
9
  こんだけ↑でよくね?
10
+
11
+
12
+
13
+ ```C
14
+
15
+ int Depth(BinNode *p) {
16
+
17
+ if (p == NULL) {
18
+
19
+ return 0;
20
+
21
+ }
22
+
23
+ int depthL = Depth(p->left);
24
+
25
+ int depthR = Depth(p->right);
26
+
27
+ return ( depthL >= depthR ) ? depthL+1 : depthR+1;
28
+
29
+ }
30
+
31
+ ```