Skip to content

Instantly share code, notes, and snippets.

@zhuharev
Created December 13, 2015 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhuharev/86623e4b2e68a85890a1 to your computer and use it in GitHub Desktop.
Save zhuharev/86623e4b2e68a85890a1 to your computer and use it in GitHub Desktop.
bin sort c#
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