Changeset 94980502 for src/examples/searchsort.c
- Timestamp:
- Mar 22, 2016, 10:19:00 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 0438091
- Parents:
- 984dce6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/searchsort.c
r984dce6 r94980502 11 11 // Created On : Thu Feb 4 18:17:50 2016 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed Feb 17 12:21:04201614 // Update Count : 4613 // Last Modified On : Tue Mar 22 22:16:46 2016 14 // Update Count : 55 15 15 // 16 16 … … 36 36 sout | *v | ", "; 37 37 } // for 38 sout | endl | endl; 39 40 // descending sort/search by changing < to > 41 for ( unsigned int i = 0; i < size; i += 1 ) { 42 iarr[i] = i + 1; 43 sout | iarr[i] | ", "; 44 } // for 45 sout | endl; 46 { 47 int ?<?( int x, int y ) { return x > y; } 48 qsort( iarr, size ); 49 for ( unsigned int i = 0; i < size; i += 1 ) { 50 sout | iarr[i] | ", "; 51 } // for 52 sout | endl; 53 for ( unsigned int i = 0; i < size; i += 1 ) { 54 int *v = bsearch( size - i, iarr, size ); 55 sout | *v | ", "; 56 } // for 57 } 38 58 sout | endl | endl; 39 59
Note: See TracChangeset
for help on using the changeset viewer.