# Find the the longest decreasing row of numbers in a vector

Show 40 post(s) from this thread on one page
Page 2 of 2 First 12
• September 23rd, 2013, 06:30 PM
jps
Re: Find the the longest decreasing row of numbers in a vector
Trace through the code and figure out where the 1 come from. Then figure out how it got there.
• September 24th, 2013, 05:15 AM
einar123
Re: Find the the longest decreasing row of numbers in a vector
Hi. This where I'm at right now.

The error comes when I test for sequence 1 3 3 5 4 2 3

Code Java:

```  package forrit;     public class Verkefni2tplus {   public static void main(String[] args) { int N = args.length; int[] a = new int[N]; int downcounter=1; int upcounter=1; int goodolddowncounter=1; for (int i = 0;i<N;i++) { a[i] = Integer.parseInt(args[i]); }   { for(int i=0;i<N-1;i++)   if (a[i]>=a[i+1]) { downcounter++; goodolddowncounter=downcounter; } else { upcounter++; } } if (upcounter>downcounter) { goodolddowncounter=downcounter; downcounter=1; }       System.out.print(goodolddowncounter); } }```

--- Update ---

int goodolddowncounter=0;
• September 24th, 2013, 09:55 AM
einar123
Re: Find the the longest decreasing row of numbers in a vector
I did the trace. It's solved. With an if loop at the bottom.
Show 40 post(s) from this thread on one page
Page 2 of 2 First 12