- File:
-
- 1 edited
-
tests/concurrent/examples/quickSort.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/examples/quickSort.c
r200fcb3 radb6b30f 9 9 // Created On : Wed Dec 6 12:15:52 2017 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : T ue Dec 4 18:00:27201812 // Update Count : 16 711 // Last Modified On : Thu Aug 16 08:17:41 2018 12 // Update Count : 163 13 13 // 14 14 … … 88 88 89 89 void usage( char * argv[] ) { 90 sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )" ;90 sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )" | endl; 91 91 exit( EXIT_FAILURE ); // TERMINATE! 92 92 } // usage … … 114 114 &sortedfile = new( (const char *)argv[2] ); // open the output file 115 115 if ( fail( sortedfile ) ) { 116 serr | "Error! Could not open sorted output file \"" | argv[2] | "\"" ;116 serr | "Error! Could not open sorted output file \"" | argv[2] | "\"" | endl; 117 117 usage( argv ); 118 118 } // if … … 121 121 &unsortedfile = new( (const char *)argv[1] ); // open the input file 122 122 if ( fail( unsortedfile ) ) { 123 serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"" ;123 serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"" | endl; 124 124 usage( argv ); 125 125 } // if … … 127 127 } // if 128 128 } // if 129 sortedfile | nlOff; // turn off auto newline130 129 131 130 enum { ValuesPerLine = 22 }; // number of values printed per line … … 138 137 for ( int counter = 0; counter < size; counter += 1 ) { // read unsorted numbers 139 138 unsortedfile | values[counter]; 140 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " ";139 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | " "; 141 140 sortedfile | values[counter]; 142 141 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 143 142 } // for 144 sortedfile | nl;143 sortedfile | endl; 145 144 if ( size > 0 ) { // values to sort ? 146 145 Quicksort QS = { values, size - 1, 0 }; // sort values 147 146 } // wait until sort tasks terminate 148 147 for ( int counter = 0; counter < size; counter += 1 ) { // print sorted list 149 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " ";148 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | " "; 150 149 sortedfile | values[counter]; 151 150 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 152 151 } // for 153 sortedfile | nl;152 sortedfile | endl | endl; 154 153 155 154 delete( values );
Note:
See TracChangeset
for help on using the changeset viewer.