SHARE
TWEET

Untitled

a guest Oct 18th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Arrays;
  2. import java.util.List;
  3. import java.util.Scanner;
  4. import java.util.stream.Collectors;
  5.  
  6. public class L02_GaussTrick {
  7.     public static void main(String[] args) {
  8.        
  9.         Scanner scanner = new Scanner(System.in);
  10.        
  11.         List<Integer> number = Arrays.stream(scanner.nextLine().split(" "))
  12.                 .map(Integer::parseInt).collect(Collectors.toList());
  13.        
  14.         int size = number.size() / 2;
  15.        
  16.         for (int i = 0; i < size; i++) {
  17.             number.set(i, number.get(i) + number.get(number.size() - 1));
  18.             number.remove(number.size() - 1);
  19.         }
  20.        
  21.         for (Integer integer : number) {
  22.             System.out.print(integer + " ");
  23.         }
  24.  
  25.     }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top