import java.util.Scanner;public class yiweishuzu { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("输入你需要的个数:"); Scanner scan = new Scanner(System.in); int n=scan.nextInt();//定义需要的阶层数n int[]array=new int[n];//定义一个n*m的数组array System.out.println("输入数组的各个元素:"); for(int i=0;i0) { sum1=sum1+array[j]; System.out.println("当前为第"+c+"个子数组,子数组和为"+sum1); c++; int a=i+1; int b=j+1; System.out.println("元素为"+a+"到"+b); } if(sum1>=sum) { sum=sum1; int d=i+1; int e=j+1; System.out.println("当前最大数组和为"+sum); System.out.println("元素为"+d+"到"+e); } } } System.out.println("最大子数组为:"+sum); } }