You are on page 1of 2

/*

* COMPRO2 Machine Problem Phase 1 (MP1)


*
* Filename: main.c
* Author : ___________________ indicate your LASTNAME, FIRSTNAME in capital
letters.
* Section : ________ indicate your section S17B, S18A or S19
* Description: _______________________________________________________
* provide a brief description of the contents of this file
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>

/* You may include other standard header file you will need in your MP, for example
time.h */

#include "dictionary.h" // DO NOT remove this line.

/*
*
* Insert your own function definitions before main().
* Alternatively, you may create a new file containing your own function
definitions.
*
*/

int
main()
{
int action, life = 3, points, Rand, Pnt;
char *Dictionary[NWORDS]; // a 1D array of character pointers (addresses)
char key[29];
int i, level;
char Words[50];

/* Declare your own local variables inside main() */

InitializeDictionary(Dictionary);

/*
*
* Insert between InitializeDictionary() and FreeDictionary() your own codes for
* your main() function to work correctly.
*
*/

printf("\t MEMORY GAME \t\n");

printf("\n\n\t [1] START GAME \t\n");


printf("\n\n\t [2] QUIT \t\n");

printf("\n\n\t [");
scanf("%d", &action);
if (action == 1){
system("cls");
printf("\n\n\t Try to remeber as much as you can! \n\n\t ");
system("pause");

// PrintDictionary(Dictionary);

while(life > 0)
{
system("cls"); //clear screen

level=+3;

for(i = 0; i <= level;i++){


Ran = rand() % NWORDS + 1;
Word[i] = D[Ran];
printf("s.\n", Word[i]);
sleep(2);
}

for(j = 0; j <= level ; j++)


{
printf("%d\n", life);
printf("\n\n\t Give a word: [");
scanf("%s", key);

if (search(Word[i], key) == 1)
{
Pnt++;
points = score(Pnt);
}
else
life--;
if (life == 0)
{
system("cls");
printf("\n\n\t GAME OVER \n\n\t ");
printf("\n\n\t SCORE: %d \n\n\t ", points);
}
system("pause");
}

#if 0 // note: change this line to #if 0 to disable PrintDictionary() call.

PrintDictionary(Dictionary);

#endif
// search(Dictionary);
FreeDictionary(Dictionary);

return 0;
}

You might also like