Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication2
- {
- class BubbleSort
- {
- private int[] array;
- public int[] Array
- {
- get { return array; }
- set { array = value; }
- }
- private DateTime start, stop;
- private TimeSpan time;
- public TimeSpan Time
- {
- get { return time; }
- set { time = value; }
- }
- private int x;
- public BubbleSort(int[] array)
- {
- this.array = array;
- x = array.Length;
- start = DateTime.Now;
- bubbleSort(x);
- stop = DateTime.Now;
- time = stop - start;
- }
- public void bubbleSort(int x)
- {
- for(int z=0; z<x; ++z){
- for(int y=0; y<x - 1; ++y){
- if(array[y]>array[y+1]){
- array[y] = array[y]^array[y+1];
- array[y+1] = array[y]^array[y+1];
- array[y] = array[y]^array[y+1];
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment