Apkawa

Untitled

Sep 23rd, 2021
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class ReverseSum2 {
  5.   public static void main(String[] args) {
  6.     int[] sum = new int[10];
  7.     Scanner scanSys = new Scanner(System.in);
  8.     while (scanSys.hasNextLine()) {
  9.       Scanner scanLine = new Scanner(scanSys.nextLine());
  10.       int curSum = 0;
  11.       int count = 0;
  12.       while (scanLine.hasNextInt()) {
  13.         if (count == sum.length) {
  14.           sum = Arrays.copyOf(sum, sum.length * 2);
  15.         }
  16.         sum[count] += scanLine.nextInt();
  17.         curSum += sum[count++];
  18.         System.out.print(curSum + " ");
  19.       }
  20.       System.out.println();
  21.     }
  22.   }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment