Changeset 200fcb3 for tests/concurrent/examples/quickSort.c
- Timestamp:
- Dec 12, 2018, 9:16:12 AM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 5ebb1368
- Parents:
- 3d99498
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/examples/quickSort.c
r3d99498 r200fcb3 9 9 // Created On : Wed Dec 6 12:15:52 2017 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : T hu Aug 16 08:17:41201812 // Update Count : 16 311 // Last Modified On : Tue Dec 4 18:00:27 2018 12 // Update Count : 167 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) ] )" | endl;90 sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )"; 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] | "\"" | endl;116 serr | "Error! Could not open sorted output file \"" | argv[2] | "\""; 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] | "\"" | endl;123 serr | "Error! Could not open unsorted input file \"" | argv[1] | "\""; 124 124 usage( argv ); 125 125 } // if … … 127 127 } // if 128 128 } // if 129 sortedfile | nlOff; // turn off auto newline 129 130 130 131 enum { ValuesPerLine = 22 }; // number of values printed per line … … 137 138 for ( int counter = 0; counter < size; counter += 1 ) { // read unsorted numbers 138 139 unsortedfile | values[counter]; 139 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | " ";140 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 140 141 sortedfile | values[counter]; 141 142 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 142 143 } // for 143 sortedfile | endl;144 sortedfile | nl; 144 145 if ( size > 0 ) { // values to sort ? 145 146 Quicksort QS = { values, size - 1, 0 }; // sort values 146 147 } // wait until sort tasks terminate 147 148 for ( int counter = 0; counter < size; counter += 1 ) { // print sorted list 148 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | " ";149 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 149 150 sortedfile | values[counter]; 150 151 if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' '; 151 152 } // for 152 sortedfile | endl | endl;153 sortedfile | nl; 153 154 154 155 delete( values );
Note: See TracChangeset
for help on using the changeset viewer.