Pointers and Memory: coding problems
Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.
0 of 7 solved
A shop keeps the prices of
nitems in an array. The manager makes a copy of the array and doubles every price in the **copy only**, for a sale report. The original array must stay exactly as it was.Print the sum of the original prices and the sum of the doubled copy, separated by one space.
**Constraints:** 1 <= n <= 1000. Each price is between -1000000000 and 1000000000. The sums can be bigger than a 32-bit integer, so use
long.**Hint:** a copy made with
clone()is a new array, so changing it does not change the original.Input. First line: n. Second line: n integers, the prices.
Output. One line with two integers: the sum of the original array, then the sum of the doubled copy.
Example 1 input
3 1 2 3
Output
6 12
Example 2 input
2 5 -4
Output
1 2