import
java.io.*;
class
Sort
{
public static void main(String args[])
throws Exception
{
int a[] = new int[10];
int n,i,j,temp;
BufferedReader br = new
BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter
the value of n : ");
n =
Integer.parseInt(br.readLine());
System.out.println(n);
for(i=0;i<n;i++)
{
System.out.print("Enter a[" + i + "] : ");
a[i] =
Integer.parseInt(br.readLine());
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i] >
a[j])
{
temp =
a[i];
a[i] =
a[j];
a[j] =
temp;
}
}
}
System.out.println("Sorted
Values are");
for(i=0;i<n;i++)
System.out.println(a[i]);
}
}
No comments:
Post a Comment