Guest User

Untitled

a guest
Jan 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication2
  7. {
  8. class BubbleSort
  9. {
  10. private int[] array;
  11.  
  12. public int[] Array
  13. {
  14. get { return array; }
  15. set { array = value; }
  16. }
  17. private DateTime start, stop;
  18. private TimeSpan time;
  19.  
  20. public TimeSpan Time
  21. {
  22. get { return time; }
  23. set { time = value; }
  24. }
  25.  
  26. private int x;
  27.  
  28. public BubbleSort(int[] array)
  29. {
  30. this.array = array;
  31. x = array.Length;
  32. start = DateTime.Now;
  33. bubbleSort(x);
  34. stop = DateTime.Now;
  35. time = stop - start;
  36. }
  37.  
  38. public void bubbleSort(int x)
  39. {
  40. for(int z=0; z<x; ++z){
  41. for(int y=0; y<x - 1; ++y){
  42. if(array[y]>array[y+1]){
  43. array[y] = array[y]^array[y+1];
  44. array[y+1] = array[y]^array[y+1];
  45. array[y] = array[y]^array[y+1];
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }
Add Comment
Please, Sign In to add comment