Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 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 SortowanieBabelkowe
  8. {
  9. class Program
  10. {
  11. static void Sortowanie(int[] tab)
  12. {
  13. int n = tab.Length;
  14. do
  15. {
  16. for (int i = 0; i < n - 1; i++)
  17. {
  18. if (tab[i] > tab[i + 1])
  19. {
  20. int temp = tab[i];
  21. tab[i] = tab[i + 1];
  22. tab[i + 1] = temp;
  23. }
  24. }
  25. n--;
  26. } while (n > 1);
  27. }
  28. static void Main(string[] args)
  29. {
  30. int[] tab = { 4, 1, 5, 3, 2 };
  31. Sortowanie(tab);
  32. foreach (var item in tab)
  33. {
  34. Console.Write(item + " ");
  35. }
  36. Console.ReadKey();
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement