SHARE
TWEET

Untitled

a guest Oct 18th, 2019 80 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.         Scanner scanner = new Scanner(System.in);
  9.         List<Integer> number = Arrays.stream(scanner.nextLine().split(" "))
  10.                 .map(Integer::parseInt).collect(Collectors.toList());
  11.  
  12.         int i = 0;
  13.         int size = number.size() / 2;
  14.         while (i < size) {
  15.             number.set(i, number.get(i) + number.get(number.size() - 1));
  16.             number.remove(number.size() - 1);
  17.  
  18.             i++;
  19.         }
  20.         //  for (int i = 0; i < number.size() / 2; i++) {
  21. //        number.set(i, number.get(i) + number.get(number.size() - 1));
  22. //        number.remove(number.size() - 1);
  23.  
  24.         for (Integer integer : number) {
  25.             System.out.print(integer + " ");
  26.         }
  27.  
  28.     }
  29. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top