1. ## Multiplying matrixes

Trying to multiply to matrixes using the following algorithm,
Code:
```ABrec(A,B)
n=A.rows; //n must be multiple of 2
C is a new n*n matrix.
if(n==1)
C[0][0]=A[0][0]*B[0][0];
else
we partion A,B,C into 4 parts;
C00=ABrec(A00,B00)+Arec(A10,B01);
C01=ABrec(A00,B01)+Arec(A01,B11);
C10=ABrec(A10,B11)+Arec(A11,B10);
C11=ABrec(A10,B01)+Arec(A11,B11);
return C;```
heres my code,
Code:
```#include <iostream>

using namespace std;

void Add(int **A,int **B,int **C,int n)
{
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
C[i][j]+=A[i][j]+B[i][j];
}
return;
}

int **AB(int **A,int **B,int **C,int n)
{
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
C[i][j]=0;
for(int k=0;k<n;++k)
C[i][j]+=A[i][k]*B[k][j];
}

}
}
int **ABrec(int **A,int **B,int **C,int n)
{

if(n==1)
C[0][0]=A[0][0]*B[0][0];
else
{
int **A00=A,**A01=A+1,**A10=A+2,**A11=A+3;
int **B00=B,**B01=B+1,**B10=B+2,**B11=B+3;
int **C00=C,**C01=C+1,**C10=C+2,**C11=C+3;

}
return C;
}

int main()
{
int **A=new int*[16],**B=new int*[16],**C=new int*[16];
for(int i=0;i<16;++i)
{
A[i]=new int[16];
B[i]=new int[16];
C[i]=new int[16];
}
for(int i=0;i<16;++i)
{
for(int j=0;j<16;++j)
{
A[i][j]=B[i][j]=C[i][j]=j+1;
}

}

C=ABrec(A,B,C,16);

}```
but the code doesnt work !!!

2. Not only does it not work, it creates tons of memory leaks, and is just a nightmare to debug.
Before going further, I strongly suggest you learn what vectors are, how to use 2d vectors and read this: SourceForge.net: Safer arrays in Cpp - cpwiki, especially about preventing out-of-bounds access.

3. Code:
`C[i][j] += A[i][j]+B[i][j];`
I don't know much about matrixes but that doesn't look like addition to me.
Kurt

4. Sorry,thats a mistake in normal method,It should be C[i][j]=A[i][j]+B[i][j],
And I know what vector is, but whats the advantage of using vector in that recursion??

5. Read the article. It explains a lot of things.