File tree Expand file tree Collapse file tree 1 file changed +23
-26
lines changed Expand file tree Collapse file tree 1 file changed +23
-26
lines changed Original file line number Diff line number Diff line change 1- //var sortTestCase = require('./sort.testcase.js');
2- //var heapSort = require('../../src/sorting/heapsort.js');
3-
4- //sortTestCase(heapSort, 'Heap sort');
5-
6-
7-
8-
9- //load('heapsort.js');
10-
11- //var arr = [];
12- //var MAX = 100
13-
14- //for(var i = 0; i < MAX; ++i){
15- // arr[i] = Math.floor((Math.random() * 100) + 1);
16- // print(arr[i]);
17- //}
18- //print(arr);
19-
20-
21-
22- //heapSort(arr);
23-
241
252var arr = [ ] ;
263var MAX = 100 ;
@@ -33,8 +10,28 @@ for(var i = 0; i < MAX; ++i){
3310 arr [ i ] = Math . floor ( ( Math . random ( ) * 100 ) + 1 ) ;
3411 // print(arr[i]);
3512}
36- console . log ( arr ) ;
37- sort ( arr ) ;
38- console . log ( arr ) ;
3913
14+ function dispArr ( arr ) {
15+ for ( var i = 0 ; i < arr . length ; ++ i ) {
16+ process . stdout . write ( arr [ i ] + " " ) ;
17+ if ( i % 10 == 9 ) {
18+ process . stdout . write ( "\n" ) ;
19+ }
20+ }
21+ if ( i % 10 != 0 ) {
22+ process . stdout . write ( "\n" ) ;
23+ }
24+ }
25+
26+
27+
28+
29+
30+
31+ //console.log(arr);
32+ dispArr ( arr ) ;
33+ sort ( arr ) ;
34+ console . log ( "" ) ;
35+ //console.log(arr);
36+ dispArr ( arr ) ;
4037
You can’t perform that action at this time.
0 commit comments