質問編集履歴
2
エラー文を記載しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -362,6 +362,8 @@
|
|
362
362
|
|
363
363
|
```
|
364
364
|
|
365
|
+
エラー文:cannot initialize return object of type 'Poly*' with an lvalue of type 'const Poly*'
|
366
|
+
|
365
367
|
|
366
368
|
|
367
369
|
初心者です。よろしければアドバイスをいただけませんか?
|
1
自分で書いたmultPolyのファンクションを更新しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -226,6 +226,14 @@
|
|
226
226
|
|
227
227
|
Poly* multPoly(const Poly* a, const Poly* b){
|
228
228
|
|
229
|
+
int i,j;
|
230
|
+
|
231
|
+
i=0;
|
232
|
+
|
233
|
+
j=0;
|
234
|
+
|
235
|
+
|
236
|
+
|
229
237
|
if(a==0)
|
230
238
|
|
231
239
|
return b;
|
@@ -236,9 +244,37 @@
|
|
236
244
|
|
237
245
|
|
238
246
|
|
247
|
+
Poly* res;
|
248
|
+
|
249
|
+
res = new Poly;
|
250
|
+
|
251
|
+
res->degree = a->degree+b->degree;
|
252
|
+
|
253
|
+
|
254
|
+
|
239
|
-
int*
|
255
|
+
int* c = new int[res->degree-1];
|
256
|
+
|
257
|
+
|
258
|
+
|
240
|
-
|
259
|
+
while(i!=res->degree){
|
260
|
+
|
241
|
-
|
261
|
+
while(j!=res->degree)
|
262
|
+
|
263
|
+
c[i+j]+=a->c[i]*b->c[j];
|
264
|
+
|
265
|
+
i++;
|
266
|
+
|
267
|
+
j++;
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
res->coeffs = c;
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
return res;
|
242
278
|
|
243
279
|
}
|
244
280
|
|
@@ -270,6 +306,14 @@
|
|
270
306
|
|
271
307
|
Poly* multPoly(const Poly* a, const Poly* b){
|
272
308
|
|
309
|
+
int i,j;
|
310
|
+
|
311
|
+
i=0;
|
312
|
+
|
313
|
+
j=0;
|
314
|
+
|
315
|
+
|
316
|
+
|
273
317
|
if(a==0)
|
274
318
|
|
275
319
|
return b;
|
@@ -280,7 +324,37 @@
|
|
280
324
|
|
281
325
|
|
282
326
|
|
327
|
+
Poly* res;
|
328
|
+
|
329
|
+
res = new Poly;
|
330
|
+
|
331
|
+
res->degree = a->degree+b->degree;
|
332
|
+
|
333
|
+
|
334
|
+
|
283
|
-
int*
|
335
|
+
int* c = new int[res->degree-1];
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
while(i!=res->degree){
|
340
|
+
|
341
|
+
while(j!=res->degree)
|
342
|
+
|
343
|
+
c[i+j]+=a->c[i]*b->c[j];
|
344
|
+
|
345
|
+
i++;
|
346
|
+
|
347
|
+
j++;
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
res->coeffs = c;
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
return res;
|
284
358
|
|
285
359
|
|
286
360
|
|