Advertisement
Lamms

SelectiveSort

Sep 20th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 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 _02SelectSort
  8. {
  9. class _02SelectSort
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14. int min = arr[0];
  15. int temp = 0;
  16.  
  17. for (int j = 0; j < arr.Length-1; j++)
  18. {
  19.  
  20. min = j;
  21. for (int i = j+1; i < arr.Length; i++)
  22. {
  23. if (arr[i] < arr[min])
  24. {
  25. temp=arr[min];
  26. arr[min] = arr[i];
  27. arr[i] = temp;
  28. }
  29. }
  30.  
  31. }
  32.  
  33. foreach (var item in arr)
  34. {
  35. Console.Write(item + " ");
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement