Welcome to pickSourcecode.com Login | Register    
pickZy.com
 Home  | search  | games  | General  | C  | C++  | Java  | Php  | Networking  | Visual Basic  | VC++  | Win32  | MFC  | JavaScript  | Jobs  | JavaScript  | Post jobs
Cpp - 2) Sort and Binary search       Share
2008-11-03 |  RatheeshTR  | Viewed: 363  |    0

#include <algorithm>
#include <vector>
#include <assert.h>
        

int main()
{

   
int ia[] = {29,23,20,22,17,15,26,51,19,12,35,40};
               

   sort( &ia[0], &ia[12] );

   bool found_it = binary_search( &ia[0], &ia[12], 18 );

   assert( found_it == false );

                

   vector< 
int > vec( ia, ia+12 );
   sort( vec.begin(), vec.end(), greater<int>() );

   found_it = binary_search( vec.begin(), vec.end(),26, greater<int>() );

                

   assert( found_it == true );

}


Comments:





Submit comment's

Type:

User Comment's:

Submitted By:
Prof: Software
Tech: C ,Cpp
Send Mail: malathi.v



Related topics
Stack Implementation
cpp stack example

General Topics
qtp data tables
qtp page checkpoint
qtp interview questions
great art
difference between application server and webserver
tips to protect your computer against virus
elemets of a defect report
measures of defect report

Web site contents © Copyright 2007, All rights reserved.
Help | Terms and Conditions | Privacy Policy | About Us