Create a simulator of chasing animals Requirements 1 Create

Create a simulator of chasing animals Requirements: (1) Create a function that displays a two dimensional array. The example uses a (2) In the main program, set the randomly selected starting locations for eaclh (3) Move each number/animal so that an animal chases the next animal. For 35 X 35 array. If the stored value is 0, show \".”, otherwise show the stored number. Hint: Use two dimensional array, nested loops, and if statement. number /animal. The example uses number 1 through number 6. example, animal # 1 chases animal # 2, animal # 2 chases animal # 3, and animal # 6 (the last animal) chases animal # 1 (the first animal). Hint: Use modulus division, as well as if statements. You may choose the direction of the movement to either four directions or eight directions. (4) Repeat Number 3 at least 20 times. Show the trace of each animals numbers. Hint: Use a loop. You may use system( \"CLS\"); to clear the screen, and system(\"pause\"); to pause after each iteration sereen, and system(\"pause\")i to pause after cach iteration

Solution

Please find below the program written in C++ that displays a 35*35 array in 2-D:

#include<iostream>
#include<fstream>

using namespace std;

int input(istream& in=cin)
{
   int x;
   in >> x;
   return x;
}

int main()
{
   int board[35][35]; //This creates a 35*25 matrix or a 2d array.

   for(int i=0; i<35; i++) //This loops on the rows.
   {
       for(int j=0; j<35; j++) //This loops on the columns
       {
           board[i][j] = input();
       }
   }

   for(int i=0; i<35; i++) //This loops on the rows.
   {
       for(int j=0; j<35; j++) //This loops on the columns
       {
           cout << board[i][j] << \" \";
       }
       cout << endl;
   }
}

 Create a simulator of chasing animals Requirements: (1) Create a function that displays a two dimensional array. The example uses a (2) In the main program, se

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site