BUBBLE_SORT OF ARRAY FOR ISC
import java.io.*;
class BUBBLE_SORT
{
public static void main(String args[])throws IOException
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
int n[]=new int[10];
for(int x=0;x<=9;x++)
{
System.out.println("enter number "+(x+1));
n[x]=Integer.parseInt(br.readLine());
}
for(int x=1;x<=9;x++)
{
for(int y=0;y<=8;y++)
{
if(n[y]>n[y+1])
{
int t=n[y];
n[y]=n[y+1];
n[y+1]=t;
}
}
}
for(int x=0;x<=9;x++)
{
System.out.print(n[x]+" ");
}
}
}
Comments
Post a Comment