Lecture 4 code

# Lecture 4 code - rtbResults.Text ="" for(int i = 0...

This preview shows pages 1–4. Sign up to view the full content.

Sheet1 Page 1 using System using System.Collections.Generic using System.ComponentModel using System.Data using System.Drawing using System.Text using System.Windows.Forms namespace Simple_sort { public partial class Form1 : Form { int [] a public Form1() { InitializeComponent() } private void btnSort_Click(object sender, EventArgs e) { int n, temp n = getA() for (int i = 0 { for (int j = i + 1 { if (a[j] < a[i]) //Swap a[i] and a[j] if a[j] is smaller { temp = a[i] a[i] = a[j] a[j] = temp } } } writeResults(n) } private void writeResults(int n)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { rtbResults.Text = "" for (int i = 0 { rtbResults.Text += a[i] + "\n" } } private int getA() { Sheet1 Page 2 int ret = 0 ret = rtbArray.Lines.Length a = new int[ret] for (int i = 0 a[i] = Convert.ToInt32(rtbArray.Lines [i].ToString ()) return ret } } } Sheet1 Page 3 //Get array values from form i < n - 1 i++) //Find smallest a[i] j < n j++) //Compare with "remaining" elements //Put sorted elements on form i < n i++) Sheet1 Page 4 i < ret i++)...
View Full Document

## This note was uploaded on 04/13/2010 for the course CIVIL 2oi4 taught by Professor Lamiar during the Fall '10 term at McMaster University.

### Page1 / 4

Lecture 4 code - rtbResults.Text ="" for(int i = 0...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online