Pointer situations...top urgent

I trying to create a matriz with pointer .this matriz is normal square for order n>1 ..Using siamese method meaning ..
ex.

step 1
1
step 2 step 3
1 1

3
2 2

step 4

8 1 6
3 5 7
4 9 2


I have the program but a i have some problems..

Please help me asap..


#include <cassert>
#include "Assign2.h"

using namespace std;
int r_size; int c_size;
int r=0; int c=0;
int lenght1=0;
int column1=0;
// Overload Operator
//magic::magic(int r, int c):r_size(r),c_size(c)
//{
//
// p=new int *[r_size];
// for (int i=0; i<r_size; i++)
// p[i]=new int [c_size];
//}

void magic::displaymatriz(int lenght)
{


cout << "Enter the Arrangement lenght\t";
cin>>lenght;
// lenght=2*lenght1+1;
r_size=2*lenght+1;
c_size=2*lenght+1;
cout <<"The Matix Will Be...."<<r_size<<","<<c_size<<endl;
// desplegar la matriz original
pmatriz=new int*[r_size] ;
for (int i=0; i<r_size;i++)
{
pmatriz[i]=new int (c_size);
for (int j=0; j<c_size; j++)
{
pmatriz[j]=new int (r_size);
}

}

cout <<"Matrix Original"<<endl;
//llenar la matriz
c=c_size/2;
for (int i =0 ; i<r_size; i++){
for (int j=0 ; j< c_size; j++){
// pmatriz[i][j]=val;
cout << pmatriz[i][j]<<"\t" ;

}
cout<<endl;
}
// Llenar matriz
for (int val=1; val<=lenght*lenght;val++){
if (r_size==-1);
{r_size=lenght-1; }
if (c==lenght){
c_size=0;}

if (pmatriz [r][c]!=0){
r_size=r_size+1;
c_size=c_size-1;

if (r_size==lenght)
r_size=0;
if (c_size==-1)
c_size=lenght-1;
r_size=r_size+1;

}

pmatriz[r_size][c_size]=val;
r_size=r_size-1;
c_size=c_size+1;
}
for (int i =0 ; i<lenght; i++){
for (int j=0 ; j<lenght; j++){

//cout <<pmatriz[i][j]<<"\t";
}
cout <<endl;
}
//fin de la matriz original
return ;
}
Topic archived. No new replies allowed.