Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Read From File And Return the max sum

s2xcrackers2xcracker Member Posts: 2
Hey everybody,So I've given a triangular pyramid of numbers with N (1<?=1000) levels. I need to write a program that finds the highest sum of numbers starting from the top level and ending at the bottom level of the pyramid. At each step I can go diagonally down to the left or diagonally down to the right as indicated by the lines joining the numbers in the diagrams below.
The first line of the input file INPUT.TXT contains N. The following N lines contain the integers for each level, separated by a single space. These integers are positive and have a maximum value of 100.
The output file OUTPUT.TXT should contain a single number, which is the maximum sum that the program has found.

Input.Txt
3
8
12 1
2 7 8

OUTPUT.TXT
27

Please help :P
Sign In or Register to comment.