Create a function to read a file full of numbers into an array
(int [][]nums
), one row of numbers from the file becomes one row
of numbers in the array. It is OK to just have an input be how many rows are
in the triangle. Signature:
public static int[][] readNums(int rows, Scanner s)
Create a function to write a triangle of numbers into a file.
public static void triwrite (int rows, PrintWriter p)
Find the maximum possible sum along any path that goes down or down and right from the top to the bottom row of your triangle.
1
1 20
1 2 30
1 3 4 50
10000 5 6 7 8
One possible path is 1, 20, 2, 4, 7, for a total of 34. Another possible path is 1,1,1,1,10000 for a total of 10004.