import java.util.*;
class Halfsearch
{
public static void main(String[] args)
{
char[] arr={'a','b','s','d','e','q','m'};
for(int x=0;x<arr.length;x++)
{
for(int y=0;y<arr.length-1-x;y++)
{
int num=new Character(arr[y]).compareTo(new Character(arr[y+1]));
if(num>0)
swap(y,y+1);
}
}
sop(arr);
}
public static void swap(int s1,int s2)
{
int num;
num=s1;
s1=s2;
s2=num;
}
public static void sop(char[] arr)
{
for(int x=0;x<arr.length;x++)
{
System.out.print(arr[x]+" ");
}
}
} |