質問編集履歴
3
コードの内容の変更と結果の提示
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,7 +16,31 @@
|
|
16
16
|
|
17
17
|
###欲しい情報
|
18
18
|
|
19
|
-
解決方法
|
19
|
+
解決方法に関する情報
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
###結果
|
24
|
+
|
25
|
+
1
|
26
|
+
|
27
|
+
0
|
28
|
+
|
29
|
+
0
|
30
|
+
|
31
|
+
0
|
32
|
+
|
33
|
+
1886912525
|
34
|
+
|
35
|
+
1835627109
|
36
|
+
|
37
|
+
1635020389
|
38
|
+
|
39
|
+
1634557804
|
40
|
+
|
41
|
+
1701535600
|
42
|
+
|
43
|
+
121
|
20
44
|
|
21
45
|
|
22
46
|
|
@@ -328,13 +352,33 @@
|
|
328
352
|
|
329
353
|
|
330
354
|
|
355
|
+
int *aps = (int*)malloc(sizeof(int)*size);
|
356
|
+
|
357
|
+
int i=0;
|
358
|
+
|
359
|
+
int past = size;
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
size = 1;
|
364
|
+
|
331
|
-
|
365
|
+
aps[0] = array_int[0];
|
366
|
+
|
367
|
+
|
368
|
+
|
332
|
-
|
369
|
+
for (i=size; i<past; i++) {
|
370
|
+
|
333
|
-
|
371
|
+
insert(aps[i]);
|
372
|
+
|
334
|
-
|
373
|
+
}
|
374
|
+
|
375
|
+
|
376
|
+
|
335
|
-
|
377
|
+
free(array_int);
|
378
|
+
|
336
|
-
|
379
|
+
array_int = aps;
|
337
|
-
|
380
|
+
|
381
|
+
|
338
382
|
|
339
383
|
return 0;
|
340
384
|
|
2
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -328,42 +328,68 @@
|
|
328
328
|
|
329
329
|
|
330
330
|
|
331
|
-
|
331
|
+
/***array_intをヒープ構造にしたい***/
|
332
|
-
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
333
|
-
|
339
|
+
return 0;
|
334
|
-
|
335
|
-
|
340
|
+
|
336
|
-
|
337
|
-
size = 3;
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
for (i=0; i<size; i++) {
|
342
|
-
|
343
|
-
aps[i] = array_int[i];
|
344
|
-
|
345
|
-
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
|
346
|
-
|
345
|
+
int main(){
|
346
|
+
|
347
|
+
|
348
|
+
|
347
|
-
|
349
|
+
size = 10;
|
350
|
+
|
351
|
+
|
352
|
+
|
348
|
-
|
353
|
+
array_int = (int *)malloc(sizeof(int)*size);
|
354
|
+
|
355
|
+
array_int[0] = 1;
|
356
|
+
|
357
|
+
array_int[1] = 13;
|
358
|
+
|
359
|
+
array_int[2] = 14;
|
360
|
+
|
361
|
+
array_int[3] = 60;
|
362
|
+
|
363
|
+
array_int[4] = 15;
|
364
|
+
|
365
|
+
array_int[5] = 91;
|
366
|
+
|
367
|
+
array_int[6] = 24;
|
368
|
+
|
369
|
+
array_int[7] = 71;
|
370
|
+
|
371
|
+
array_int[8] = 80;
|
372
|
+
|
373
|
+
array_int[9] = 63;
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
HeapSort();
|
378
|
+
|
379
|
+
|
380
|
+
|
349
|
-
for (; i<
|
381
|
+
for (int i=0; i<size; i++) {
|
350
|
-
|
382
|
+
|
351
|
-
in
|
383
|
+
printf("%d\n",array_int[i]);
|
352
|
-
|
384
|
+
|
353
|
-
}
|
385
|
+
}
|
354
|
-
|
355
|
-
|
386
|
+
|
387
|
+
|
356
388
|
|
357
389
|
|
358
390
|
|
359
391
|
free(array_int);
|
360
392
|
|
361
|
-
array_int = aps;
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
393
|
|
368
394
|
|
369
395
|
return 0;
|
@@ -372,60 +398,4 @@
|
|
372
398
|
|
373
399
|
|
374
400
|
|
375
|
-
int main(){
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
size = 10;
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
array_int = (int *)malloc(sizeof(int)*size);
|
384
|
-
|
385
|
-
array_int[0] = 1;
|
386
|
-
|
387
|
-
array_int[1] = 13;
|
388
|
-
|
389
|
-
array_int[2] = 14;
|
390
|
-
|
391
|
-
array_int[3] = 60;
|
392
|
-
|
393
|
-
array_int[4] = 15;
|
394
|
-
|
395
|
-
array_int[5] = 91;
|
396
|
-
|
397
|
-
array_int[6] = 24;
|
398
|
-
|
399
|
-
array_int[7] = 71;
|
400
|
-
|
401
|
-
array_int[8] = 80;
|
402
|
-
|
403
|
-
array_int[9] = 63;
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
HeapSort();
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
for (int i=0; i<size; i++) {
|
412
|
-
|
413
|
-
printf("%d\n",array_int[i]);
|
414
|
-
|
415
|
-
}
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
free(array_int);
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
return 0;
|
426
|
-
|
427
|
-
}
|
428
|
-
|
429
|
-
|
430
|
-
|
431
401
|
```
|
1
コードが間違ってました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,12 +4,6 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
###エラー内容
|
8
|
-
|
9
|
-
HeapSort()内のinsert(i);の内部のshiftdown()で「Thread 1: EXC_BAD_ACCESS (code=1, address=0x10851ec9c)」というエラーが起きます。理由は多分、i>>sizeだからだと思います。
|
10
|
-
|
11
|
-
|
12
|
-
|
13
7
|
###条件
|
14
8
|
|
15
9
|
なるべく関数を書き換えたくないです。(名称は絶対に)
|
@@ -334,11 +328,39 @@
|
|
334
328
|
|
335
329
|
|
336
330
|
|
337
|
-
int
|
331
|
+
int *aps = (int*)malloc(sizeof(int)*size);
|
338
|
-
|
339
|
-
|
340
|
-
|
332
|
+
|
341
|
-
in
|
333
|
+
int i=0;
|
334
|
+
|
335
|
+
int past = size;
|
336
|
+
|
337
|
+
size = 3;
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
for (i=0; i<size; i++) {
|
342
|
+
|
343
|
+
aps[i] = array_int[i];
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
for (; i<past; i++) {
|
350
|
+
|
351
|
+
insert(array_int[i]);
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
size = past;
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
free(array_int);
|
360
|
+
|
361
|
+
array_int = aps;
|
362
|
+
|
363
|
+
|
342
364
|
|
343
365
|
|
344
366
|
|