[Nottingham] Introduction and Java Question
James Dobson
dob_3001 at yahoo.co.uk
Sun Oct 19 11:57:10 UTC 2008
Hi,
Would be a two/three liner in perl ;) but I think you just need to put the results into a array and then when it comes to printing them out just loop through the results and print the result out.
Maybe put all the results into 2D array i.e.
[
Mean = [ X ],
Medium = [ X ],
Mode = [ X, Y],
]
That way you can just loop through each key value to return the results and not do something specific for just mode.
JD
--- On Sun, 10/19/08, Jason Liquorish <jason at dropshock.com> wrote:
> From: Jason Liquorish <jason at dropshock.com>
> Subject: Re: [Nottingham] Introduction and Java Question
> To: nottingham at mailman.lug.org.uk
> Date: Sunday, October 19, 2008, 12:12 PM
> On Sun, 19 Oct 2008 11:23:59 +0100
> Jason Liquorish <jason at dropshock.com> wrote:
>
> > On Sun, 19 Oct 2008 11:21:42 +0100
> > David Aldred <david at familyaldred.org.uk> wrote:
> >
> > > ...so you need to count instances of numbers read
> from the list,
> > > then sort by the count. The mode is the highest
> in the sort - if
> > > there's more than one highest count then you
> print both/all.
> > >
> >
> > Yep that is what I need to do, I have tried a few
> things including if
> > statements and while loops but I just cannot seem to
> get it working. I
> > was creating an array and putting all the numbers into
> that, then I
> > had a second array which I input the count of each
> number in the first
> > array into the corresponding index, this obviously
> left redundant data
> > laying about but I could not get it working correctly
> anyway =(
> >
>
> I have had a breakthrough and I can now find the most
> recurring number
> in the array, my only problem now is if two or more numbers
> occur the
> same amount of times I am not sure how to print them all
> out.
>
> My code is here http://dpaste.com/85429/
>
> --
> Jason Liquorish <jason at dropshock.com>
>
> _______________________________________________
> Nottingham mailing list
> Nottingham at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/nottingham
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Nottingham
mailing list