metehan92 has asked for the wisdom of the Perl Monks concerning the following question:
It's strange, after the last input taken in, the program just freezes, CPU usage for the process jumps up to 14% and it just sits there, I've tried putting in print statements to check my progress, but it doesn't help. Any ideas?1 2 3 4
#!/usr/bin/perl $i1 = <>; chomp($i1); for ($count = 0; $count < $i1; $count++) { $i2 = <>; $i3 = <>; chomp $i2; chomp $i3; my @values; @values = split(/ /, $i3); my @differences; my $count1; my $count2; my $min; for ($count1 = 0; $count1 < $i2; $count++) { for ($count2 = $count1+1; $count2<$i2; $count2++) { if($count1 = 0 and $count2 = 1) { $min =abs($values[$count1]-$values[$count2]); } elsif($min> abs($values[$count1]-$values[$count2])) { $min = abs($values[$count1]-$values[$count2]); } } } print $min; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with a programming problem.
by GrandFather (Saint) on Sep 06, 2012 at 02:30 UTC | |
|
Re: Help with a programming problem.
by Anonymous Monk on Sep 06, 2012 at 00:10 UTC | |
|
Re: Help with a programming problem.
by philiprbrenan (Monk) on Sep 06, 2012 at 00:44 UTC | |
|
Re: Help with a programming problem.
by Anonymous Monk on Sep 06, 2012 at 00:46 UTC | |
|
Re: Help with a programming problem.
by grizzley (Chaplain) on Sep 06, 2012 at 06:57 UTC |