回答編集履歴

1

追記

2016/11/17 13:13

投稿

himakuma
himakuma

スコア952

test CHANGED
@@ -1 +1,249 @@
1
1
  namespaceに対しての } が足りないように見えますが?
2
+
3
+
4
+
5
+ } 以前にエラーでませんか?
6
+
7
+ 下記の修正コードで実行までできました
8
+
9
+
10
+
11
+ ```C#
12
+
13
+ using System;
14
+
15
+
16
+
17
+ namespace List
18
+
19
+ {
20
+
21
+ class MainClass
22
+
23
+ {
24
+
25
+ public static void Main(string[] args)
26
+
27
+ {
28
+
29
+ Console.WriteLine("Hello World!");
30
+
31
+ List<int> a = new List<int>();
32
+
33
+ List<double> b = new List<double>();
34
+
35
+ a.Add(10);
36
+
37
+ a.Add(20);
38
+
39
+ a.Add(30);
40
+
41
+ b.Add(40);
42
+
43
+
44
+
45
+ for (int i = 0; i < a.Length; i++)
46
+
47
+ {
48
+
49
+ Console.WriteLine(a.Get(i));
50
+
51
+ }
52
+
53
+ }
54
+
55
+ }
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+ class List<T>
64
+
65
+ {
66
+
67
+ public T[] a;
68
+
69
+ public int Length;
70
+
71
+
72
+
73
+ public List()
74
+
75
+ {
76
+
77
+ Length = 0;
78
+
79
+ a = new T[0];
80
+
81
+ }
82
+
83
+
84
+
85
+
86
+
87
+ public void Add(T v)
88
+
89
+ {
90
+
91
+ T[] b = new T[a.Length + 1];
92
+
93
+ for (int i = 0; i < a.Length; i++)
94
+
95
+ {
96
+
97
+ b[i] = a[i];
98
+
99
+ }
100
+
101
+ b[a.Length] = v;
102
+
103
+ a = b;
104
+
105
+ Length = b.Length;
106
+
107
+ }
108
+
109
+
110
+
111
+ public T Get(int i)
112
+
113
+ {
114
+
115
+ return a[i];
116
+
117
+ }
118
+
119
+
120
+
121
+ public void Delete(T v)
122
+
123
+ {
124
+
125
+ T[] c = new T[a.Length - 1];
126
+
127
+ for (int i = 0; i < a.Length; i++)
128
+
129
+ {
130
+
131
+ c[i] = a[i];
132
+
133
+ }
134
+
135
+ c[a.Length] = v;
136
+
137
+ a = c;
138
+
139
+ Length = c.Length;
140
+
141
+ }
142
+
143
+ }
144
+
145
+
146
+
147
+
148
+
149
+ class Stack
150
+
151
+ {
152
+
153
+ List<int> y;
154
+
155
+ int head;
156
+
157
+ int tail;
158
+
159
+
160
+
161
+ Stack(List<int> y, int head, int tail)
162
+
163
+ {
164
+
165
+ this.y = new List<int>(); // ←配列的に定義しているのは型が違うから無理
166
+
167
+ this.head = 0;
168
+
169
+ this.tail = y.Length + 1;
170
+
171
+ }
172
+
173
+
174
+
175
+ public static void main(List<int> y, int head, int tail)
176
+
177
+ {
178
+
179
+ Stack stack = new Stack(y, head, tail); // ←コンストラクタを定義しているので引数なしは不可
180
+
181
+
182
+
183
+ }
184
+
185
+
186
+
187
+ public void Push(int i)
188
+
189
+ {
190
+
191
+ for (int x = 0; x < y.Length; x++)
192
+
193
+ {
194
+
195
+ y.Add(i);
196
+
197
+ }
198
+
199
+ }
200
+
201
+ public void Pop(int i)
202
+
203
+ {
204
+
205
+ for (int x = 0; x < y.Length; x++)
206
+
207
+ {
208
+
209
+ y.Delete(i);
210
+
211
+ }
212
+
213
+ }
214
+
215
+
216
+
217
+ }
218
+
219
+
220
+
221
+ class Queue
222
+
223
+ {
224
+
225
+ public Queue()
226
+
227
+ {
228
+
229
+ }
230
+
231
+ public void Push(int i)
232
+
233
+ {
234
+
235
+ List<int> z = new List<int>();
236
+
237
+ z.Add(i);
238
+
239
+ z.Delete(i);
240
+
241
+ }
242
+
243
+ }
244
+
245
+
246
+
247
+ }
248
+
249
+ ```