Beginner has problem。Can anyone have a look at my code?

I'm trying to get the coordinates of a 9x9 flat grid. The first point start at the origin. The current code has output but is apparently wrong.

Code:

`#include<math.h>`

#include<stdio.h>

#define pi 3.1415926

double initial( int Nbead, double Rold[3][Nbead],int Nx)

{int i;

for (i=0;i<Nbead;i++){

Rold[0][i] = (floor(i/Nx)-1)+1;

Rold[1][i] = (i%Nx);

Rold[2][i] = 0.0;

}

return Rold[3][Nbead];

}

int main()

{

int Nx=9;

int Ny=9;

double aa=1;

int Nbead=Nx*Ny; /*total number of beads*/

double Rold[3][Nbead];

int Nbond=2*Nx*Ny-Nx-Ny;/*total number of bonds*/

int j,k;

/*get the position (a flat sheet)*/

double initial(int Nbead, double Rold[3][Nbead],int Nx);

for (k=0;k<Nbead;k++)

{

for (j=0;j<3;j++)

printf("the j is %d, the k is %d, Rold is %d\n",j, k,Rold[j][k]);

printf("\n");

}

return 0;

}