import java.io.*;
class mybubble_input
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int i,j,temp,n,l;
System.out.println("enter the length of numbers u want to sort");
n=Integer.parseInt(br.readLine());
int a[]=new int[n];
l=a.length;
System.out.println("enter unsorted numbers");
for(i=0;i
{
a[i]=Integer.parseInt(br.readLine());
}
System.out.println("the numbers before sorting");
for(i=0;i
{
System.out.print(a[i]+" ");
}
System.out.println(" ");
for(i=0;i
{
for(j=0;j
{
if(a[j]>a[j+1])
{
temp = a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
}
System.out.println("numbers after sorting");
for(i=0;i
{
System.out.print(a[i]+" ");
}
}
}
No comments:
Post a Comment