I have to take a 2d array of [6][8] floats that represent a star map and add the four surrounding numbers to it to measure it's intensity of light. Would something like make sense???
for(i=0;i<6;i++)
{
for(j=0;j<8;j++)
{
stars[i][j+1] + stars[i+1][j] + stars[i-1][j] + stars[i][j-1];}}
instead of writing many lines of this type of code:
stars[1][1] = stars[1][1] + stars[0][1] + stars[2][1] + stars[1][0] + stars[1][2]
Also, I'm reading in the array from a text file with all integers, the array is declared and initialized as 0.0. When I add the numbers in the four surrounding spaces for one position as a test, I get 33 which is the correct answer. When I try to divide that number by 5.0 to get an integer, I get 28.2 instead of 6.6. I tried doing
(float)stars[i][j]
after reading in the int values from the file, but to no avail.
Any suggestions on that?
thanks.