import java.io.*;
class InsertionSort
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int a[]=new int[4];
int t,i,j;
for(i=0;i<4;i++)
{
t=Integer.parseInt(br.readLine());
a[i]=t;
}
for(i=1;i<a.length;i++)
{ t=a[i];
System.out.println("pass :"+i);
for(j=i-1;j>=0 && t<a[j];j--)
{
System.out.println("exchange");
a[j+1]=a[j];
}
a[j+1]=t;
}
for(i=0;i<a.length;i++)
{
System.out.println(a[i]);
}
}
}
class InsertionSort
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int a[]=new int[4];
int t,i,j;
for(i=0;i<4;i++)
{
t=Integer.parseInt(br.readLine());
a[i]=t;
}
for(i=1;i<a.length;i++)
{ t=a[i];
System.out.println("pass :"+i);
for(j=i-1;j>=0 && t<a[j];j--)
{
System.out.println("exchange");
a[j+1]=a[j];
}
a[j+1]=t;
}
for(i=0;i<a.length;i++)
{
System.out.println(a[i]);
}
}
}
No comments:
Post a Comment