258 Arrays Chapter 7 6 using System.ComponentModel; 7 (Web server version)

258 Arrays Chapter 7 6 using System.ComponentModel; 7 using System.Windows.Forms; 8 using System.Data; 9 public class BubbleSorter : System.Windows.Forms.Form 11 { 12 private System.Windows.Forms.Button sortButton; 13 private System.Windows.Forms.Label outputLabel; 14 15 // Visual Studio .NET generated code 16 17 [STAThread] 18 static void Main() 19 { Application.Run( new BubbleSorter() ); 21 } 22 23 private void sortButton_Click( object sender, 24 System.EventArgs e ) 25 { 26 int[] a = { 2,6,4,8,10,12,89,68,45,37 }; 27 28 outputLabel.Text = “Data items in original ordern”; 29 for ( int i = 0; i < a.Length; i++ ) 31 outputLabel.Text += " " + a[ i ]; 32 33 // sort elements in array a 34 BubbleSort( a ); 35 36 outputLabel.Text += "nnData items in ascending ordern"; 37 38 for ( int i = 0; i < a.Length; i++ ) 39 outputLabel.Text += " " + a[ i ]; 41 } // end method sortButton_Click 42 43 // sort the elements of an array with bubble sort 44 public void BubbleSort( int[] b ) 45 { 46 for ( int pass = 1; pass < b.Length; pass++ ) // passes 47 48 for ( int i = 0; i < b.Length - 1; i++ ) // one pass 49 if ( b[ i ] > b[ i + 1 ] ) // one comparison 51 Swap( b, i ); // one swap 52 } 53 54 // swap two elements of an array 55 public void Swap( int[] c, int first ) 56 { 57 int hold; // temporary holding area for swap 58 Fig. 7.10 Sorting an array with bubble sort. (Part 2 of 3.)
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Leave a Reply