If you want to know how a program works, plzzzzzzzzzzzz post a program. Or try reading the Rules for the site.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
What I believe the problem is asking you to do is set up the 2D array.
Read in the temperatures along the edges (is the temperature the same all along an edge or does it vary along the edge, particularly near the corners?)
Once the edges are initialized, begin processing the interior nodes. Your formula is a bit off, I think the array references should be more like
( T(i-1,j) +T(i,j-1) + T(i,j+1) + T(i+1,j) )/4
this visits the elements above, below, right and left of the current node at (i,j)
But a problem I see is that as you start out, say from the top left position, is that there is no current data in the nodes to the right and below. Does the assignment address the initial state of all nodes?
vmanes
Posting Virtuoso
1,914 posts since Aug 2007
Reputation Points: 1,268
Solved Threads: 228
For your array, if the problem is given as a set size, just declare a local array, as you show int plate[10][10]; for example.
If no specific info is given for initial state of interior nodes, you might consider assigning them the average of the edge temperatures - that at least puts them in the approximate range. Then assign the temperature values to the edge nodes.
For the evaluation step, simply run nested for loops that only visit the interior nodes. Using the array declaration above, something like
int r, c;
for( r = 1; r < 9; r++ )
for( c = 1; c < 9; c++ )
{
//process the node by averaging the up/down/left/right nodes
}
This row by row approach might be a bit simplistic, and tend to give more weight to the upper left temperature. Perhaps a better approach is to somehow spiral around the nodes, working from outer edges towards the center
Now your turn - write some code. Start simple, get some parts working and build upon them.
vmanes
Posting Virtuoso
1,914 posts since Aug 2007
Reputation Points: 1,268
Solved Threads: 228