All pastes #356683 Raw Edit

Untitled

public java v1 · immutable
·published 2007-02-15 06:17 UTC
rendered paste body
public class Test{		public static void main(String args[]){				int[] myArray = {3,7,-11,485,-486};					int max = -9999999;		int sum = 0;		int start = 0;		int end   = 0;		int track = 0;				for(int i=0; i < myArray.length; i++){						sum = sum + myArray[i];						if(sum > max){				max = sum;				end = i;				start = track;			} // end if						if(sum < 0){				track = i+1;			} // end if		} // end for			System.out.println("Max sum is    : " + max);	System.out.println("Starting index: " + start);	System.out.println("Ending index  : " + end);					}} // end class