/*
*Sort.java
* Author Mahesh-cse-b520
*created on 30/12/2011
*Sorting of 5 numbers
*/
import java.lang.*;
class Sort
{
public static void main(String args[])
{
int arr[]=new int[5];
arr[0]=4;
arr[1]=3;
arr[2]=5;
arr[3]=1;
arr[4]=2;
for(int i=0;i<4;i++)
{
int small=i;
for(int j=i;j<5;j++)
{
if(arr[j]<arr[small])
small=j;
}
int temp=arr[i];
arr[i]=arr[small];
arr[small]=temp;
}
for(int i=0;i<5;i++)
System.out.println(arr[i]+"");
}
}
No comments:
Post a Comment