Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

What Am I Doing Wrong?

Name: Anonymous 2008-05-22 22:02

http://javabat.com/prob?id=AP1.scoresIncreasing

public boolean scoresIncreasing(int[] scores) {
  boolean increase = true;
 
  for (int i = 1; ((i) < (scores.length + 1)); i++){
  if (scores[i] > scores[i+1]){
  increase = false;
  }
  }
 
  return increase;
}

Name: Anonymous 2008-05-23 1:48


bool sortedIncr(int[] a) {
  for (int i = 1; i < a.size; i++) if (a[i - 1] > a[i]) return false;
return true;
}


No need to keep checking once you've found an element out of order.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List