标签:exti bsp blog image rate util str log port
import java.util.Scanner; public class Test { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in=new Scanner(System.in); System.out.println("请输入数组的长度:"); int length=in.nextInt(); System.out.println("请输入一个数组:"); int[] a=new int [length]; for(int i=0;i<length;i++) { a[i]=in.nextInt(); } int max=a[0]; int sum=0; for(int m=0;m<length;m++) { if(sum<=0) { sum=a[m]; } else { sum+=a[m]; } if(sum>max) { max=sum; } } System.out.println("子数组最大的和为"+max); } }
标签:exti bsp blog image rate util str log port
原文地址:http://www.cnblogs.com/1998lu/p/6665127.html