Solved

# dats goes missing

Posted on 1998-11-11

where dos the first line of data go? I can get over this problem a few ways, but would like to know.

also sugest any inprovments.

#include<iostream.h>

#include<stdlib.h>

#include<conio.h>

#include<iomanip.h>

float main()

{

register int i, j, count;

float **grid;

int x, y, k, print = 0, test = 0;

cout << "Define the size of the grid ie. x y :";

cin >> x >> y;

grid = (float **)calloc(x, sizeof(float *));

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

grid[k] = (float *)calloc(y, sizeof(float));

cout << "Enter the values" << endl;

for(j = 1; j < (y - 1); j++)

cin >> grid[0][j];

clrscr();

cout << "processing please wait..." << "\n\n\n";

for(count = 0; count < 100; count++){

for(i = 1; i < (x - 1); i++){

for(j = 1; j < (y - 1); j++){

grid[i][j] = .25 * (grid[i + 1][j] + grid[i - 1][j] +

grid[i][j + 1] + grid[i][j - 1]);

if(print == 1){

cout << setiosflags(ios::fixed) << grid[i][j] << " ";

}

}

if(print == 1){

cout << "\n";

}

if(count >= 99){

print = 1;

}

}

}

return 0;

}