Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   lowest to highest (http://www.chiefdelphi.com/forums/showthread.php?t=57929)

seanl 18-06-2007 20:04

lowest to highest
 
how would i go about arranging mixed up numbers in an array from lowest to highest. the length is set to x. so you dont know what the numbers are because the user is going to be entering the numbers
heres what i got so far its in java but the part i need should be the same as C++.
public static void main(String[]args)
{
EasyReader IO=new EasyReader();
System.out.println("How many numbers do you want to enter?");
int length=IO.readInt();
int numbers[]=new int [length];
for(int x=0;x<length;x++)
{
System.out.println("please enter your "+(x+1)+"st number");
numbers[x]=IO.readInt();
}
int highLow[]=highLow(numbers,length)
//int median=median();


}
public static int[] highlow(int[]numbers,int length)
{
int[]highLow=new int[length];

for(int x=0; x<length;x++)
{
for(int(y=0; y<length;y++)
{

}
}
}

bear24rw 18-06-2007 21:07

Re: lowest to highest
 
http://www.developerfusion.co.uk/show/3653/9/

Check out that page it seems to be what your looking for

notaPINKtruck 18-06-2007 21:14

Re: lowest to highest
 
Java libs do this for you.

Code:

import java.util.Arrays;
public static void main(String[]args)
{
  EasyReader IO=new EasyReader();
  System.out.println("How many numbers do you want to enter?");
  int length=IO.readInt();
  int numbers[]=new int [length];
  for(int x=0;x<length;x++)
  {
    System.out.println("please enter your "+(x+1)+"st number");
    numbers[x]=IO.readInt();
  }
 
  Arrays.sort(numbers);
 
  //int median=median();
}

http://java.sun.com/j2se/1.4.2/docs/...il/Arrays.html

seanl 18-06-2007 21:36

Re: lowest to highest
 
i didnt know of that thanks alot. that just made life so easier.


All times are GMT -5. The time now is 00:15.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi