title: Disease Outbreak Simulation using SIR model
body: <p>I have a homework where I have to write a C++ program to simulate a disease outbreak using SIR model (Susceptible, Infectious, Recover). The requirement is to use a 2D-array with 7x7 size where user will choose an X and Y coordinate to initialize an infectious person. A Susceptible person (S) will become infected (I) if there is an infected person in adjacent. Then an infected person will recover (R) if there is a Recover person in adjacent. The program will end if all people are recovered. 
  Example output:</p>
  
  <pre><code>Day 0                          Day 1                       Day 2
  s s s s s s s                  s s s s s s s               s s s s s s s
  s s s s s s s                  s s s s s s s               s i i i i i s
  s s s s s s s                  s s i i i s s               s i r r r i s
  s s s i s s s                  s s i r i s s               s i r r r i s
  s s s s s s s                  s s i i i s s               s i r r r i s
  s s s s s s s                  s s s s s s s               s i i i i i s
  s s s s s s s                  s s s s s s s               s s s s s s s
  </code></pre>
  
  <p>So far, I can only check the state in position (1,1), (1,7), (7,1), (7,7). If the next three position next to it have an infected person, it will update the state to nextDayState. 
  Here is my code so far for two functions, SpreadingDisease and RecoverState.</p>
  
  <pre><code>    void recoverState(char currentDayState[SIZE][SIZE], char nextDayState[SIZE][SIZE], int sizeOfArray)//It will take in the currentState of Day 0. I also copy the elements in currentState to nextDayState so that it could work. 
  {
      for (int i = 1; i &lt; sizeOfArray + 1; ++i)
      {
          for (int j = 1; j &lt;= sizeOfArray + 1; ++j)
          {
              if (currentDayState[i][j] == 'i')//If found any Infected, update it to Recover on the nextDayState array. 
              {
                  nextDayState[i][j] == 'r';
              }
          }
      }
  
      for (int i = 1; i &lt; sizeOfArray + 1; ++i)
      {
          for (int j = 1; j &lt;= sizeOfArray + 1; ++j)
          {
              currentDayState[i][j] = nextDayState[i][j];
              //After all people are recover, update the currentState and output it to terminal. 
          }
      }
  }
  void spreadDisease(const char currentDayState[SIZE][SIZE], char nextDayState[SIZE][SIZE], int sizeOfArray, int day = 1)
  {
      for (int i = 1; i &lt; sizeOfArray + 1; ++i)
      {
          for (int j = 1; j &lt;= sizeOfArray + 1; ++j)
          {
              if (currentDayState[i][j] == 's')
              {
                  if (i == 1 &amp;&amp; j == 1)
                  {
                      if (currentDayState[1][2] == 'i' || currentDayState[2][1] == 'i' || currentDayState[2][2] == 'i')
                      {
                          nextDayState[1][1] = 'i';
                      }
                  }
                  if (i == 1 &amp;&amp; j == 7)
                  {
                      if (currentDayState[1][6] == 'i' || currentDayState[2][6] == 'i' || currentDayState[2][7] == 'i')
                      {
                          nextDayState[1][7] = 'i';
                      }
                  }
                  if (i == 7 &amp;&amp; j == 1)
                  {
                      if (currentDayState[6][1] == 'i' || currentDayState[6][2] == 'i' || currentDayState[7][2] == 'i')
                      {
                          nextDayState[7][1] = 'i';
                      }
                  }
                  if (i == 7 &amp;&amp; j == 7)
                  {
                      if (currentDayState[6][6] == 'i' || currentDayState[7][6] == 'i' || currentDayState[6][7] == 'i')
                      {
                          nextDayState[7][7] = 'i';
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>I figure out that If I can somehow get the X and Y coordinate from the user, then I can use that coordinate to update the state of the next day. Unfortunately, I don't know how to assign the X and Y coordinate into the function to start with it.</p>
  
  <p>P/S: Thank you for all of your answers. I very appreciate your kindness. However, I should have mentioned the requirement of my assignment before. Since I only study till the User-Defined Functions part, I am not allowed to use anything else beyond that. So I am limited to use 2D-array, If-else, Looping only to solve this problem. Map and Vector is far beyond my knowledge right now xD. </p>