Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
154
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 insertionsort
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] mas = new int[5];
  14. int temp;
  15. for (int a = 0; a <mas.Length; a++)
  16. {
  17. mas[a] = Convert.ToInt32(Console.ReadLine().ToString());
  18. }
  19. for (int i = 1; i <mas.Length; i++)
  20. {
  21. for (int j = i; j > 0 && mas[j - 1] > mas[j]; j--)
  22. {
  23. // swap(x[j - 1], x[j]);
  24. temp = mas[j];
  25. mas[j] = mas[j - 1];
  26. mas[j - 1] = temp;
  27. }
  28. }
  29.  
  30. foreach (int el in mas)
  31. {
  32. Console.WriteLine(el);
  33. }
  34. Console.ReadLine();
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement