using System;
public class Test
{
public static void Main()
{
int T = Convert.ToInt32(Console.ReadLine());
for(int i=0;i<T;i++)
{
string[] unsorted = Console.ReadLine().Split(' ');
int[] numbers = Array.ConvertAll(unsorted,int.Parse);
InsertionSort(numbers);
Print(numbers);
}
}
public static void InsertionSort(int[] a)
{
int n= a.Length;
int j=0,flag=0;
for(int i=1;i<n;i++)
{
int key = a[i];
j=i-1;
while(j>=0 && a[j]>key)
{
a[j+1]=a[j];
j--;
}
a[j+1]=key;
}
}
public static void Print(int[] a)
{
foreach(int i in a)
{
Console.WriteLine(i);
}
}
}
public class Test
{
public static void Main()
{
int T = Convert.ToInt32(Console.ReadLine());
for(int i=0;i<T;i++)
{
string[] unsorted = Console.ReadLine().Split(' ');
int[] numbers = Array.ConvertAll(unsorted,int.Parse);
InsertionSort(numbers);
Print(numbers);
}
}
public static void InsertionSort(int[] a)
{
int n= a.Length;
int j=0,flag=0;
for(int i=1;i<n;i++)
{
int key = a[i];
j=i-1;
while(j>=0 && a[j]>key)
{
a[j+1]=a[j];
j--;
}
a[j+1]=key;
}
}
public static void Print(int[] a)
{
foreach(int i in a)
{
Console.WriteLine(i);
}
}
}
Comments
Post a Comment