Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.41 KB | None | 0 0
  1.       for(k = 0; k < NUMSTEPS; k++)
  2.                 {
  3.                         printf("Step: %d\n", k);
  4.                                 for (i = 1; i < (Y + 1); i++)
  5.                                 {
  6.                                         for (j = 1; j < (X + 1); j++)
  7.                                         {
  8.                                                  if (cycleSwitch == 0)
  9.                                                  {
  10.                                                       resultArray[i][j] = ((sourceArray[i][j] + sourceArray[i][(j - 1)] + sourceArray[i][(j + 1)] + sourceArray[(i - 1)][j] + sourceArray[(i + 1)][j]) / 5);
  11.                                                  }
  12.                                                  else
  13.                                                  {
  14.                                                       sourceArray[i][j] = ((resultArray[i][j] + resultArray[i][(j - 1)] + resultArray[i][(j + 1)] + resultArray[(i - 1)][j] + resultArray[(i + 1)][j]) / 5);
  15.                                                  }
  16.                                         }
  17.                                 }
  18.                         if(cycleSwitch == 0)
  19.                         {
  20.                                 cycleSwitch = 1;
  21.                         }
  22.                         else
  23.                         {
  24.                                 cycleSwitch = 0;
  25.                         }
  26.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement