Re: TWO loops and ONE if statement

2007-07-03 Thread Randal L. Schwartz
> ""Amichai" == "Amichai Teumim" <[EMAIL PROTECTED]> writes: "Amichai> I need to sort the @array from lowest to highest using TWO loops and "Amichai> ONE if statement. That's why it's so confusing. "Amichai> I could use a one liner to do all this. I need to do it however as "Amichai> above men

Re: TWO loops and ONE if statement

2007-07-03 Thread Chas Owens
On 7/3/07, Amichai Teumim <[EMAIL PROTECTED]> wrote: I forgot to add what I have done so far. I did: #!/usr/bin/perl use strict; use warnings; my @array = (5,3,2,1,4); my $n = @array; for my $i (0 .. $n-1) { for my $j (0 .. $n-1) { if ($array[$j+1] < $array[$j]) { #compare the two

Re: TWO loops and ONE if statement

2007-07-03 Thread Mumia W.
On 07/03/2007 02:53 AM, Amichai Teumim wrote: Hi guys Hello Amichai. [...] I need to sort the @array from lowest to highest using TWO loops and ONE if statement. That's why it's so confusing. I could use a one liner to do all this. I need to do it however as above mentioned. How can I do th

Re: TWO loops and ONE if statement

2007-07-03 Thread Martin Barth
Hi maybe this wikipedia article can show you different sorting algorithems: http://en.wikipedia.org/wiki/Sorting_algorithm#Summaries_of_popular_sorting_algorithms there are examples in pseudocode. HTH, Martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: TWO loops and ONE if statement

2007-07-03 Thread Jeff Pang
Amichai Teumim 写道: Hi guys You guys have been giving me some very good ideas. Very efficent ways of doing things. For this excercise that I'm trying to figure out I actually need the following inefficient way: #!/usr/bin/perl @array = (5,3,2,1,4); ## include your code here ## foreach $elem

Re: TWO loops and ONE if statement

2007-07-03 Thread Paul Johnson
On Tue, Jul 03, 2007 at 10:53:18AM +0300, Amichai Teumim wrote: > You guys have been giving me some very good ideas. Very efficent ways > of doing things. > For this excercise that I'm trying to figure out I actually need the > following inefficient way: > > > #!/usr/bin/perl > > @array = (5,3,