Saturday 8 August 2009

Descending Order

public class descending{
public static void main(String [] args){
int [] myarray=new int [10];
int c=0,i=0,k=10,l=0,t=0;
int x=0;
SimpleInput y;
y=new SimpleInput();
while(c<10){
x=y.getInt("Enter Number");
myarray[c]=x;
c++;
}
c=0;
while(k>0){
while(c<9)
{
l=myarray[c];
t=c+1;
i=myarray[t];
if(i>l){
myarray[c]=i;
myarray[t]=l;}
c++;
}
c=0;
k--;
}
c=0;
while(c<10){
System.out.println(myarray[c]);
c++;
}
}
}

No comments:

Post a Comment