Ignore:
Timestamp:
Mar 22, 2016, 10:19:00 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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
Message:

update examples

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/searchsort.c

    r984dce6 r94980502  
    1111// Created On       : Thu Feb  4 18:17:50 2016
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Wed Feb 17 12:21:04 2016
    14 // Update Count     : 46
     13// Last Modified On : Tue Mar 22 22:16:46 2016
     14// Update Count     : 55
    1515//
    1616
     
    3636                sout | *v | ", ";
    3737        } // 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        }
    3858        sout | endl | endl;
    3959
Note: See TracChangeset for help on using the changeset viewer.