Код: Выделить всё
public static void main(String[] args) {
int arr[]= {0,-1,2,-3,5,9,-5,10};
int max_ending_here=0;
int max_so_far=0;
int start =0;
int end=0;
for(int i=0;i< arr.length;i++)
{
max_ending_here=max_ending_here+arr[i];
if(max_ending_here
Подробнее здесь: [url]https://stackoverflow.com/questions/14180308/finding-the-start-and-end-index-for-a-max-sub-array[/url]