A Running Bank Balance
Halcyon Bank prints a balance column beside every line of a statement, so a customer can see what the account stood at all the way through the month rather than only at the end of it. The account opens the period at zero. Transactions are listed in the order they cleared, with a deposit written as a positive amount and a withdrawal as a negative one. The balance column has exactly one entry per transaction, and each entry is the balance after that transaction has gone through.
Task: Print the statement's balance column.
Input
The first line holds a single integer n, the number of transactions. Each of the next n lines holds one amount, negative for a withdrawal.
Output
One line holding n balances, in transaction order, separated by single spaces. Write each as a whole number, with no decimal point.
Example:
Input:
4
100
-30
50
-20
Output:
100 70 120 100
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in