明耀

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
import java.util.*;
public class Main
    {
    public static void main(String[] args)
        {
        Scanner sr=new Scanner(System.in 

);
        while(sr.hasNext())
            {
            String str=sr.nextLine();
            String[] strs=str.split(" ");
            int[] num=new int[strs.length];
            for(int i=0;i<strs.length;i++)
              {
                num[i]=Integer.valueOf(strs[i]);
            }  
            int sum=0;
            int max=Integer.MIN_VALUE;
            for(int i=0;i<num.length;i++)
                {
                sum+=num[i];
                if(sum>max)
                    max=sum;
                if(sum<0)
                    sum=0;
            }
            System.out.println(max);
        }
    }
}

 

posted on 2017-08-26 16:18  明耀  阅读(204)  评论(0编辑  收藏  举报