Need help for homework!!

(C++ Programing Help) Can someone help me with this program?

Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagonally down to the right. The number of rows in the triangle is >1 but <=100. The numbers in the triangle, all integers, are between 0 and 99.
Input Data: Data about the number of rows in the triangle are first read from the input file. In our example, the input file appears as follows:
5 // This triangle has 5 rows
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
Output Data 1. Display the triangle if and only if its size is <= 15, as shown below:
Triangle size = 5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
2. Display the highest sum (30 in our example) and the path (row, column and value) as shown below.
( 0, 0) - 7
( 1, 0) - 3
( 2, 0) - 8
( 3, 1) - 7
( 4, 1) - 5
=== 30
3. (Optional) In addition to the above output, if the number of rows <= 15 display the path a second time as shown below.
|7|
|3 _|
|8 _ _|
|_ 7 _ _|
|_ 5 _ _ _|
Highest sum = 30.
(((((The code has been given like this: ))))
#include
using namespace std;
const int MAXTBLSIZE = 100; // the maximum table size is 100

int main( void )
{
string fileName[] = {"T0.txt", "T1.txt", "T2.txt", "T3.txt", "T4.txt", "T5.txt", "T6.txt", ""};
int trg[MAXTBLSIZE][MAXTBLSIZE] = {0};
int trgSize; // triangle size (number of rows)
int choice = 1; // to stop the program to allow the user to see the results one table at a time

// test loop: takes the names of 7 input files from an array
for (int i = 0; choice == 1 && fileName[i] != ""; i++)
{
readTrg(fileName[i], trg, trgSize);
printTrg(table, trgSize);
findPath(); // needs parameters
printPath(); // needs parameters

cout << "Please enter 1 to continue 0 to stop" << endl;
cin >> choice;
}

return 0;
} // main
Last edited on
Same problem as here:
http://www.cplusplus.com/forum/general/263719/#msg1137349

Same comments apply.
Registered users can post here. Sign in or register to post.