Mar 8, 2012 at 11:59am UTC
#include <iostream>
#include <time.h>
#include <windows.h>
using namespace std;
int main();
{
//1 //variable declaration
char board[16] = {};
bool inviboard[16] = {};
int turn = 0;
int n = 1;
char answer, answer_question;
clock_t start, end;
cout<<" ****************************************************"<<endl;
cout<<" ****************************************************"<<endl;
cout<<" ****************************************************"<<endl;
cout<<" ****************************************************"<<endl;
cout<<" ***************** W E L C O M E ******************"<<endl;
cout<<" ****************************************************"<<endl;
cout<<" ****************************************************"<<endl;
cout<<" ** **** * ***** *** * ** * ***** * ***"<<endl;
cout<<" ** **** ******* ******* * ** * ** * * *** * * *** **"<<endl;
cout<<" ** **** *** *** * ** * * ** * ** * ** * **"<<endl;
cout<<" ** **** ******* ******* *** * ** * *** *** * *** **"<<endl;
cout<<" ** * *** ******* **** ** ** *** *** * ***"<<endl;
cout<<" ****************************************************"<<endl;
cout<<endl;
cout<<endl;
cout<<" START [Y/N]: "<<endl;
cin>>answer;
if (answer=='Y' || answer=='y')
{//x
start = clock();
cout<<"Player 1: Complete the phrase, God is ______, all the time."<<endl;
cout<<"Player 2: Compute 1000 + 400 + 30 + 4 = ______."<<endl;
cout<<"Done? [Y/N]: ";
cin>>answer_question;
if (answer_question=='Y' || answer_question=='y')
{//y
do
{//2
system("cls");
for(int i=0; i<12; i += 4)
{ // sets the board //3
cout<< board[i] << "|" << board[i+1] << "|" << board[i+2] << "|" << board[i+3] <<endl;
cout<< "-+-+-+-" <<endl;
}//3
cout << board[12] << "|" << board[13] << "|" << board[14] << "|" << board[15] <<endl;
do
{//4
cout << "\nEnter square number: "; // Prompts the location of turn
cin >> n;
} //4
while(inviboard[n-1] == true && n > 0 && n <= 16);
if (turn % 2 == 1)
{//5
cout << "Enter letter: ";
cin >> answer;
board[n-1] = answer;
inviboard[n-1] = true;
}//5
else
{//6
cout << "Enter single number: ";
cin >> answer;
board[n-1] = answer;
inviboard[n-1] = true;
}//6
turn++;
if (board[0] == 'g')
{ // looks if a player won//7
if (board[1] == 'o' && board[2] == 'o' && board[3] == 'd')
{//8
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//8
else if(board[4] == 'o' && board[8] == 'o' && board[12] == 'd')
{//9
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//9
else if(board[5] == 'o' && board[10] == 'o' && board[15] == 'd')
{//10
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//10
}//7
else if (board[1] == 'g' && board[5] == 'o' && board[9] == 'o' && board[13] == 'd')
{//11
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//11
else if (board[2] == 'g' && board[6] == 'o' && board[10] == 'o' && board[14] == 'd')
{//12
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//12
else if (board[3] == 'g' && board[7] == 'o' && board[11] == 'o' && board[15] == 'd')
{//13
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//13
else if (board[4] == 'g' && board[5] == 'o' && board[6] == 'o' && board[7] == 'd')
{//14
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//14
else if (board[8] == 'g' && board[9] == 'o' && board[10] == 'o' && board[11] == 'd')
{//15
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//15
else if (board[12] == 'g')
{//16
if (board[13] == 'o' && board[14] == 'o' && board[15] == 'd')
{//17
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//17
if (board[9] == 'o' && board[6] == 'o' && board[3] == 'd')
{//18
cout << "Player 2 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//18
}//16
if (board[0] == '1')
{//19
if (board[1] == '4' && board[2] == '3' && board[3] == '4')
{//20
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//20
else if(board[4] == '4' && board[8] == '3' && board[12] == '4')
{//21
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//21
else if(board[5] == '4' && board[10] == '3' && board[15] == '4')
{//22
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//22
}//19
else if (board[1] == '1' && board[5] == '4' && board[9] == '3' && board[13] == '4')
{//23
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//23
else if (board[2] == '1' && board[6] == '4' && board[10] == '3' && board[14] == '4')
{//24
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//24
else if (board[3] == '1' && board[7] == '4' && board[11] == '3' && board[15] == '4')
{//25
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//25
else if (board[4] == '1' && board[5] == '4' && board[6] == '3' && board[7] == '4')
{//26
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//26
else if (board[8] == '1' && board[9] == '4' && board[10] == '3' && board[11] == '4')
{//27
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//27
else if (board[12] == '1')
{//28
if (board[13] == '4' && board[14] == '3' && board[15] == '4')
{//29
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//29
if (board[9] == '4' && board[6] == '3' && board[3] == '4')
{//30
cout << "Player 1 wins";
end = clock();
cout<<start<<"-"<<end<<endl;
turn = 15;
}//30
}//28
if (turn == 15)
{//31
cout << "\nDo you want to play again(y/n)?"; //Prompts the user to play again
cin >> answer;
if (answer == 'y' || answer == 'Y')
{//32
for (int i = 0; i < 16; i++)
{//33
board[i] = 0;
inviboard[i] = false;
}//33
turn = 0;
n = 1;
}//32
else
{//34
cout << "Thanks for Playing!";
end = clock();
cout<<start<<"-"<<end<<endl;
system("pause>0");
exit(1);
}//34
}//31
system("pause>0");
}//2
while(turn < 16);
}//y
else if(answer_question='N' || answer_question=='n')
{
cout<<"Bye bye";
end = clock();
cout<<start<<"-"<<end<<endl;
}
else if (answer=='N' || answer=='n')
{
cout<<"Bye bye";
end = clock();
cout<<start<<"-"<<end<<endl;
}
return 0 ;
}//x
return 0 ;
}//1
Please take the time to read this. Whenever we compile it the program'd say that there's a missing header file. And we can't really figure it out. Thank you in advance,
Mar 8, 2012 at 12:04pm UTC
int main();
<-- start by deleting the ;
Mar 8, 2012 at 12:05pm UTC
after deleting it. it said that the program has 77 errors and 1 warning. :-/
Mar 8, 2012 at 12:21pm UTC
The first error says " error C2059: syntax error : '}' "
and when i click to to find where's the error located it'll lead me to line 12.
Mar 8, 2012 at 12:29pm UTC
try making line 12 and 13:
1 2
char board[16];
bool inviboard[16];
edit also noticed you have
else if (answer_question='N' || answer_question=='n' )
near the bottom of the code, should be
else if (answer_question=='N' || answer_question=='n' )
Last edited on Mar 8, 2012 at 12:33pm UTC
Mar 8, 2012 at 12:59pm UTC
its working now! thank you so much!!!