Using the following code, how do i get the cat to eat a mouse? What i want the program to do is to have the user input cordinates to where the cat should go to eat the mouse. Once it eats the mouse, I guess the mouse should no longer show up on the grid.
Can someone help me get started?
So far I have been able to at least get the cin and couts for the user to enter the cordinates but i havent been able to do anything with that :(
// Cat and Mouse.cpp : main project file.
#include <ctime>
#include <iostream>
usingnamespace std;
int main()
{
time_t t;
srand((unsigned) time(&t));
char maze[8][8];
int x, y, count;
for(x=0;x<8;x++)
for (y=0;y<8;y++)
maze[x][y] = '.';
maze[7][0] = 'C'; // Cat
for (count =0;count<3;count++)
{
do
{
x=rand()%8; // random row
y=rand()%8; // random column
}while (maze[x][y]!='.'); // So we don't over-write a used space
maze[x][y]='M';// place mouse at maze[x][y]
}
for(x=0;x<8;x++)
{
for (y=0;y<8;y++)
{
cout << maze[x][y]<< " ";
}
cout << endl;
}
return 0;
}