Here's the code that was in the file:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define ROWS 8
#define COLS 8
void initializer(int arr[ROWS][COLS])
{
int x,y;
for(x=0;x<ROWS;x++)
{
for(y=0;y<COLS;y++)
{
arr[x][y]=0;
}
}
}
void number(int num[8][8])
{
char name[100];
/* for user to input their name*/
printf("\n\n*****Welcome to Manhattan Tourist Problem!*******\n\n");
printf("Please Key in your name:");
scanf("%s",name);
printf("****Good day %s , let start the game...ALL THE BEST!******\n");
printf("Press any key to start the game \n");
getch();
}
void display(int num[8][8])
{
int x, y=0;
/*to generate the number */
srand(time(0));
for(x=0;x<8;x++)
{
for (y=0;y<8;y++)
{
num[x][y]= rand() %10;
if(y==0)
{
printf(" | | | | | | | | \n");
}
if(num[0][0]=0)
{
printf("|%d|",num[x][y]);
}
else
{
printf(" %d ",num[x][y]);
}
printf("-");
}
printf("\n");
}
printf("\n");
}
void action(int num[8][8])
{
int attrac=0;
int x,y=0;
char choice;
char input;
int total;
int row=8,col=8;
printf("Number of attraction visited so far: %d \n",attrac);
attrac+=num[x][y];
printf("\n\nEach number in the map represent the number of attractions along each street,You may only move to the right or move down!\n\n");
printf("Press 'D' to move down\n");
printf("Press 'R' to move to the right\n");
printf("Press 'Q' to Exit the game\n");
printf("Please enter your next action:%c",input);
scanf("%c",&input);
printf("\n");
if(input == 'R' || input == 'r'){
x++;
num[x][y]=1;
}
if(input == 'D' || input == 'd'){
y++;
num[x][y]=1;
}
printf("\n\nCongratulation, You have complted the tour!\n\n");
printf("Total attractions you have visited: %d \n",total);
printf("Thanks for playing!! See You Again!");
}
int main()
{
int arr[ROWS][COLS],attrac;
initializer(arr);
number(arr);
display(arr);
action(arr);
}