Ok. I have been working on a math program for quite a while now, with limited success.

You may have seen my other project before, which involved a triangular Matrix. But that has changed.

This program utilizes a square matrix that adds to a square (if you have Excel or any other similar program, now's the time to break that out.)

Start at cell A,1. The value here is 1. Now pretend that outside the chamber of cells (A,-1) are 0. Add the column down, similar to the Fibonacci Sequance, but instead of adding the 2 preceding numbers, you add all of them. The values in colum A should be: 1,1,2,4,...

Now heres the tricky part.

Go to colum B. Now you must add ACROSS as well as down

(colum B: 1,2,5,12)

do the same for colum C (2,5,14,29)

and D (4, 12, 39, 110)

Heres what it looks like:

1 1 2 4

1 2 5 12

2 5 14 39

4 12 39 110

Now here is My current problem, My code does not turn that out,

It turns out a strange sequance (I will show the area that we did, a [4x4] matrix)

|1|1|2|4|

|0|1|3|11|

|1|3|9|31|

|2|7|23|81|

as you can see there is a problem, and i have not a clue as to what it does. Here is the code, and it is well comented. If could PLEASE PLEASE PLEASE PLEASE help that would make my life.

I have spent the past month looking at this with a dumb founded look on.

If you have questions please be specific, this is a kind of confusing concept for all involved (my matmatician dad didnt get the matrix) and it doesnt help when theres a generic "i dont get what it does, can you explain it better?" question.

THANKS IN ADVANCE!!!

Code:#include <cstdlib> #include <iostream> #include <cmath> #include <cstdio> #include <fstream> using namespace std; //Variables int row; //Used for placing rows in matrix int col; //col number int state_row; int state_col; //used as another portion to the rule int pre = 0; int size_row; int size_col; int matrix[10][10]; int sub; // Functions void txtclr() //Text Clear, used to clear the out file before the next print { ofstream UM("Out.txt", ios::out); //Opens "Out.txt" for clean, overwriting UM.flush(); UM.close(); } void rule() { size_row = 10; //numbers of rows ( -- ) size_col = 10; //Number or colums ( | ) for( state_col = 0; state_col != size_col; state_col++ ) //collum switch { pre = 0; //return pre to 0 for( state_row = 0; state_row != size_row; state_row++ ) //row switch { matrix[0][0] = 1; for(row = 0; row != state_row; row++) //Vert. addition (|) { pre = matrix[row-1][state_col] + pre; } for(col = 0; col != state_col; col++) //horiz. addition (-) { pre = matrix[state_row][col] + pre; } matrix[state_row][state_col] = pre; } } } void txtprnt() //Text Print, prints out the data from rule() to a file { rule(); //Runs the Rule ofstream UM("Out.txt", ios::out | ios::app); //Dump arrays onto "Out.txt" at end of for( row = 0; row != size_row; row++) //Used to advance to next row once the first row is completed { UM << "|"; //Visual Character cout << "|"; //View Real time generation for( col = 0; col != size_col; col++ ) //Matrix Colum Builder { UM << matrix[row][col] << "|"; //Print the number in the space [row]x[col], and a Visual Character cout << matrix[row][col] << "|"; //View Real time generation } UM << '\n'; //once row completed, move down a line cout << '\n'; //View Real time generation } UM.flush(); UM.close(); system("pause"); } //Program int main(int argc, char *argv[]) { txtclr(); //Clear text txtprnt(); //Print text [Generate numbers] return 0; }