class sort
{
public static void main(String args[])
{
int sum, i,j,temp = 0;
int []a = new int[5];
for(i=0;i< 5;i++)
a[i] = Integer.parseInt(args[i]);
for(i=0;i< 5;i++)
{
for(j=i+1;j< 5;j++)
{
if (a[i] < a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
for(i=0;i< 5;i++)System.out.println(a[i]);
}
}
/*output:3 2 9 8 4(input)
sorting order is 2 3 4 8 9 */
Sunday, September 28, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment