Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace insertionsort
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] mas = new int[5];
- int temp;
- for (int a = 0; a <mas.Length; a++)
- {
- mas[a] = Convert.ToInt32(Console.ReadLine().ToString());
- }
- for (int i = 1; i <mas.Length; i++)
- {
- for (int j = i; j > 0 && mas[j - 1] > mas[j]; j--)
- {
- // swap(x[j - 1], x[j]);
- temp = mas[j];
- mas[j] = mas[j - 1];
- mas[j - 1] = temp;
- }
- }
- foreach (int el in mas)
- {
- Console.WriteLine(el);
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement