Discussion topic: Contributed Answer/Explanation to Q. 12
To go to the homepage of this topic,
click here.
Home: jisha | Original Message | Reply | Subject: Contributed Answer/Explanation to Q. 30 | :-
import java.io.*;
class Bubble25
{
public static void main(String args[])throws IOException
{
DataInputStream in=new DataInputStream(System.in);
int i,j,tmp;
int a[]=new int [5];
System.out.println("Enter the elements");
for(i=0;i<5;i++)
{
a[i]=Integer.parseInt(in.readLine());
}
for(i=0;i<5;i++)
for(j=i+1;j<5;j++)
{
if (a[j]<a[i])
{
tmp=a[i];
a[i]=a[j];
a[j]=tmp;
}
}
System.out.println("Array in order is");
for(j=0;j<5;j++)
{
System.out.println(a[j]);
}
}
}
Posted at: Thu Feb 18 15:04:04 2010 (GMT) |
Page 1 of 1 | From: jisha | Reply 1 of 1 | Reply | | Subject: Contributed Answer/Explanation to Q. 30 | :-
import java.io.*;
class Bubble25
{
public static void main(String args[])throws IOException
{
DataInputStream in=new DataInputStream(System.in);
int i,j,tmp;
int a[]=new int [5];
System.out.println("Enter the elements");
for(i=0;i<5;i++)
{
a[i]=Integer.parseInt(in.readLine());
}
for(i=0;i<5;i++)
for(j=i+1;j<5;j++)
{
if (a[j]<a[i])
{
tmp=a[i];
a[i]=a[j];
a[j]=tmp;
}
}
System.out.println("Array in order is");
for(j=0;j<5;j++)
{
System.out.println(a[j]);
}
}
}
Posted at: Thu Feb 18 15:05:47 2010 (GMT)
|
Page 1 of 1
|
|
To post to this forum, you must be signed in as a Syvum member.
Please sign in / register as a member.