1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <string>
#include <iostream>
#include <Windows.h>
#include <cstring>
using namespace std;
int hangprocessnum = 1;
int guessesleft = 7;
int randword = rand() % 9;
char guessingword[4] = {'_', '_', '_', '_'};
char list[7] = {'_', '_','_','_','_','_','_'};
char guesschar;
char wordlist[10] = {'past', 'word', 'dogs', 'goat', 'done', 'game', 'book', 'like', 'ball', 'fast'};
char wordanswer[1];
char wordtotal[1];
bool lost = false;
bool won = false;
int _tmain();
void draw(int hpn);
void guess();
void guess()
{
wordanswer[0] = wordlist[randword];
wordtotal[0] = guessingword[0] + guessingword[1] + guessingword[2] + guessingword[3];
if (strcmp (wordtotal[0], wordanswer[0]) == 0)
{
won = true;
}
draw(hangprocessnum);
for (int i = 0; i <= 7; i++)
{
cout << list[i] << " ";
}
cout << endl;
cout << "Guesses left: " << guessesleft;
cout << endl;
cout << "Word: ";
for (int n = 0; n <= 4; n++)
{
cout << guessingword[n];
}
cout << endl;
cout << "Guess a letter >> ";
cin >> guesschar;
cin.get();
guessesleft--;
guess();
}
void draw(int hpn)
{
...
}
int _tmain()
{
guess();
cin.get();
return 0;
}
|