Advertisement
Ash_HeLiX

Day3Home6.1

Oct 14th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Home6._1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] array = new int[30];
  14. int stepSort = 1;
  15. int tempSort;
  16.  
  17. Random random = new Random();
  18.  
  19. for (int i = 0; i < array.Length; i++)
  20. {
  21. array[i] = random.Next(10, 99);
  22. Console.Write(array[i] + " ");
  23. }
  24.  
  25. Console.WriteLine();
  26. while (stepSort != 0)
  27. {
  28. stepSort = 0;
  29. for (int i = 0; i < array.Length-1; i++)
  30. {
  31. if (array[i] < array[i + 1])
  32. {
  33. tempSort = array[i];
  34. array[i] = array[i + 1];
  35. array[i + 1] = tempSort;
  36. stepSort++;
  37. }
  38. }
  39. }
  40.  
  41. for (int i = 0; i < array.Length; i++)
  42. {
  43. Console.Write(array[i] + " ");
  44. }
  45. Console.WriteLine();
  46.  
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement