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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
#include<iostream>
#include<conio.h>
#include<string>
#include<cstdlib>
#include<ctime>
using namespace std;
int pause() //Funtion for pause
{
int in;
scanf("%c",&ch);
getint();
return 0;
}
int main ()
{
int Go= 1, numbers_ctr=0;
cout<< "Welcome to Guess Game" <<endl;
//I'm inserting a message so that when the game loads the user will be welcomed into the game.
//This is the Character Array
char coveredarray [3][3] = {{'?','?','?'},
{'?','?','?'},
{'?','?','?'}};
for(int row = 0; row < 3; row++)
{
for(int column = 0; column < 3; column++)
{
cout << coveredarray[row][column] << " ";
}
cout << endl;
}
//This is the Guess Array
int randarray[3][3] = {{0,0,0},
{0,0,0},
{0,0,0}};
srand(unsigned time(0));
int randarray[3][3] = rand()%9 + 1;
for(int row = 0; row < 3; row++)
for(int column = 0; column < 3; column++)
cout << randarray[row][column];
float num[3][3];
int row , column; // Spelling of column is incorrect
cout << "Please enter the row to enter a number between 1-3 " << endl;
cin >> row;
if (boardarray[column] [row] != 0 )
{
randarray[row][column] = 0 ; /
/If you get the number wrong then it will appear as a 0
}
while (Go < 21)
{
cout<<endl;
cout<< "Go"<<endl;
cout<< "Numbers found:"<<numbers_ctr<<" "<<"Numbers yet to be found:"<<10 - numbers_ctr<<endl;
if((play_row < 1) || (play_row > 3))
{
cout<< "Remember, choose between 1 - 3"<<endl;
//This will stop the user entering numbers larger than the grid
system("pause");
continue;
if((play_column < 1) || (play_column > 3))
cout << "Please enter the column to enter a number between 1-3" << endl;
cin >> column;
if (playarray[column] [row] =<9)
{
cout<< "Remember, choose between 1 - 9"<<endl;
//This will stop the user entering numbers larger than the grid
system("pause");
continue;
cout<<"Please enter a number between 1-9 "<<endl;
cin >> num[row-1][column-1];
}
{
if (playarray[row][column] =<9) ;
// The number will change if you get the right answer
{
cout<< "Number Found"<<endl;
coveredarray[play_row-1][play_column-1] = ;
numbers_ctr++;
for (int row=0; row<3; row++)
{
for(int column=0; column<3; column++)
{
cout<<coveredarray[row][column]<<" ";
}
cout<<endl;
}
}
else
//This will show an F to show the flagged area the user has been before
{
cout<<" Please Try againe "<<endl;
coveredarray[play_row-1][play_column-1] = 0;
for(int row=0; row <3; row++)
{
for(int column=0; column<3; column++)
{
cout<<actualarray[row][column]<<" ";
}
cout<<endl;
while (Go < 21)
{
cout<<endl;
cout<< "Go"<<endl;
cout<< "Numbers found:"<<numbers_ctr<<" "<<"Numbers yet to be found:"<<10 - numbers_ctr<<endl;
else
//This will show an F to show the flagged area the user has been before
{
cout<<" Wrong Number "<<endl;
actualarray[play_row-1][play_column-1] = 'F';
for(int row=0; row <3; row++)
{
for(int column=0; column<3; column++)
{
cout<<actualarray[row][column]<<" ";
}
cout<<endl;
if(array[play_row-1][play_column-1] == 1)
{
cout<<" That position has already been selected please choose another row and column "<<endl;
system("pause");
continue;
}
array[play_row-1][play_column-1]=1;
if(numbers_ctr == 9)
{
cout<<" You have won "<<endl;
break;
}
Go++;
}
}
if(Go==21)
{
cout<<" You have reached your number of goes. "<<endl;
}
_getch();
}
|