daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Nov 17th, 2017 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.nio.charset.StandardCharsets;
  5. import java.util.*;
  6.  
  7. public class Main {
  8.   /**
  9.    * Iterate through each line of input.
  10.    */
  11.   public static void main(String[] args) throws IOException {
  12.     InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
  13.     BufferedReader in = new BufferedReader(reader);
  14.     String[] strNums;
  15.     strNums = in.readLine().split(",[ ]*");
  16.     int sequence[] = new int[strNums.length];
  17.    
  18.     int max = Integer.MIN_VALUE;
  19.     for (int i = 0; i < strNums.length; ++i){
  20.       sequence[i] = Integer.parseInt(strNums[i]);
  21.       if (i - 1 > 0){
  22.         int current = sequence[i] + sequence[i - 1];
  23.         if (current > max){
  24.             max = current;
  25.         }
  26.       }
  27.     }
  28.    
  29.     System.out.println(max);
  30.    
  31.     // while ((line = in.readLine().split("\\s")) != null) {
  32.     //   System.out.println(line);
  33.     // }
  34.    
  35.     // //int  sequence[] =
  36.   }
  37. }
RAW Paste Data
Top