Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class ReverseSum2 {
- public static void main(String[] args) {
- int[] sum = new int[10];
- Scanner scanSys = new Scanner(System.in);
- while (scanSys.hasNextLine()) {
- Scanner scanLine = new Scanner(scanSys.nextLine());
- int curSum = 0;
- int count = 0;
- while (scanLine.hasNextInt()) {
- if (count == sum.length) {
- sum = Arrays.copyOf(sum, sum.length * 2);
- }
- sum[count] += scanLine.nextInt();
- curSum += sum[count++];
- System.out.print(curSum + " ");
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment