Created
December 13, 2015 13:44
-
-
Save zhuharev/86623e4b2e68a85890a1 to your computer and use it in GitHub Desktop.
bin sort c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace ConsoleApplication22 { | |
class App { | |
static void Main(string[] args) | |
{ | |
InsertBin(); | |
} | |
static void InsertBin() | |
{ | |
int[] A = { 3, 8, 4, 3, 2, 7, 10, 5 }; | |
int i, j; | |
int n = 8; | |
int m, l, r, k; | |
Console.WriteLine("Исходный массив:"); | |
for (i = 0; i < n; i++) | |
Console.Write("{0} ", A[i]); | |
j = 0; | |
int temp = 0; | |
for ( i = 1; i < A.Length; i++) | |
{ | |
j = i; | |
temp = A[i]; | |
while ((j > 0) && (A[j - 1] > temp)) | |
{ | |
A[j] = A[j - 1]; | |
j--; | |
} | |
A[j] = temp; | |
} | |
Console.WriteLine(" "); | |
Console.WriteLine(" "); | |
Console.WriteLine("Отсортированый массив:"); | |
for (i = 0; i < n; i++) | |
Console.Write("{0} ", A[i]); | |
Console.Read(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment