课堂作业
static Scanner in=new Scanner(System.in); public static void main (String[] args) throws InterruptedException{ int n[]=new int[200]; System.out.println("输入数组长度"); int nn; nn=in.nextInt(); System.out.println("请输入数组"); for(int i=0;i<n;i++) { n[i]=in.nextInt(); } int m1[]=new int[200]; int m=0; int m2=0; int b=0; int s=0; int sign=0; m2=n[0]; for(int i=0;i<n;i++) { if(m<=0) { m=n[i]; m1[i]=m; b=i+1; }else { m+=n[i]; m1[i]=m; } if(m2<m) { m2=m; System.out.println("当前最大子数组和:" + m2); }else{ System.out.println("当前最大子数组和:" + m2); } sign++; s=i+1; System.out.println("组成最大子数组的数为第"+ b +"个数到第"+s+"个数"); System.out.println("当前已检测"+ s +"个子数组"); Thread.sl
}