Web hosting uk - Chapter 7 Arrays 263 23 private System.ComponentModel.Container components
Chapter 7 Arrays 263 23 private System.ComponentModel.Container components = null; 24 25 int[] a = { 0, 2,4, 6, 8,10,12,14,16, 26 18, 20, 22, 24, 26, 28 }; 27 28 // Visual Studio .NET generated code 29 30 // main entry point for application 31 [STAThread] 32 static void Main() 33 { 34 Application.Run( new BinarySearchTest() ); 35 } 36 37 // searches for an element by calling 38 // BinarySearch and displaying results 39 private void findButton_Click( object sender, 40 System.EventArgs e ) 41 { 42 int searchKey = Int32.Parse( inputTextBox.Text ); 43 44 // initialize display string for the new search 45 outputLabel.Text = “Portions of array searchedn”; 46 47 // perform the binary search 48 int element = BinarySearch( a, searchKey ); 49 50 if ( element != -1 ) 51 displayLabel.Text = “Found value in element ” + 52 element; 53 else 54 displayLabel.Text = “Value not found”; 55 56 } // end findButton_Click 57 58 // searchs array for specified key 59 public int BinarySearch( int[] array, int key ) 60 { 61 int low = 0; // low subscript 62 int high = array.Length - 1; // high subscript 63 int middle; // middle subscript 64 65 while ( low <= high ) 66 { 67 middle = ( low + high ) / 2; 68 69 // the following line displays the portion 70 // of the array currently being manipulated during 71 // each iteration of the binary search loop 72 BuildOutput( a, low, middle, high ); 73 74 if ( key == array[ middle ] ) // match 75 return middle; Fig. 7.12 Binary search of a sorted array. (Part 2 of 4.)
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.