عنوان 

 سورس بازی دوز X-O سی پلاس

نوع فایل

فرمت

سورس زبان سی پلاس پلاس

CPP , EXE

پیش نمایش از سورس کد پروژه

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

void draw();
void userchoice();
void compchoice();
int win();
int done = 0;
char ttt[6][6] = {
{‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘},
{‘ ‘, ‘۱’, ‘³’, ‘۲’, ‘³’, ‘۳’},
{‘ ‘, ‘ؤ’ ,’إ’, ‘ؤ’, ‘إ’, ‘ؤ’},
{‘ ‘, ‘۴’, ‘³’, ‘۵’, ‘³’, ‘۶’},
{‘ ‘, ‘ؤ’ ,’إ’, ‘ؤ’, ‘إ’, ‘ؤ’},
{‘ ‘, ‘۷’, ‘³’, ‘۸’, ‘³’, ‘۹’}
};
int main()
{
char temp;
draw();
do
{
if(done == 0)
{
userchoice();
done = win();
}

if(done == 0)
{
compchoice();
done = win();
}
else
{
if(done == 1)
{cout << “You have won!!!\n\n\n”;}
else
{cout << “The game is a draw, there is no winner.\n\n\n”; done++;}
}

if(done == 1)
{cout << “The computer has beaten you…\nYOU MORON!!!!!!\n\n\n”;}
if(done == 2)
{cout << “The game is a draw, there is no winner.\n\n\n”;}
} while(done == 0);
cout << “Enter a key, followed by\n<Enter>, to quit…\n”;
cin >> temp;
return 0;
}
void draw()
{
int r, c;

textmode(C40);
clrscr();
for(r = 0; r <= 5; r++)
{
for(c = 0; c <= 5; c++)
{cout << ttt[r][c];}
cout << endl;
}
}
void userchoice()
{
int choice, error;
char temp;
do
{
choice = 1;
error = 0;
gotoxy(1, 10);
cout << “\n\n\nPlease enter the number of the square\n”
<< “that you wish to put an X in: “;
cin >> choice;
switch (choice)
{
case 1:
if((ttt[1][1] == ‘X’) || (ttt[1][1] == ‘O’))
{error++;}
else
{ttt[1][1] = ‘X’;}
break;
case 2:
if((ttt[1][3] == ‘X’) || (ttt[1][3] == ‘O’))
{error++;}
else
{ttt[1][3] = ‘X’;}
break;
case 3:
if((ttt[1][5] == ‘X’) || (ttt[1][5] == ‘O’))
{error++;}
else
{ttt[1][5] = ‘X’;}
break;
case 4:
if((ttt[3][1] == ‘X’) || (ttt[3][1] == ‘O’))
{error++;}
else
{ttt[3][1] = ‘X’;}
break;
case 5:
if((ttt[3][3] == ‘X’) || (ttt[3][3] == ‘O’))
{error++;}
else
{ttt[3][3] = ‘X’;}
break;
case 6:
if((ttt[3][5] == ‘X’) || (ttt[3][5] == ‘O’))
{error++;}
else
{ttt[3][5] = ‘X’;}
break;
case 7:
if((ttt[5][1] == ‘X’) || (ttt[5][1] == ‘O’))
{error++;}
else
{ttt[5][1] = ‘X’;}
break;
case 8:
if((ttt[5][3] == ‘X’) || (ttt[5][3] == ‘O’))
{error++;}
else
{ttt[5][3] = ‘X’;}
break;
case 9:
if((ttt[5][5] == ‘X’) || (ttt[5][5] == ‘O’))
{error++;}
else
{ttt[5][5] = ‘X’;}
break;
default:
error++;
break;
}
if(error != 0)
{
cout << “Enter a key, followed by\n<Enter>, to continue…\n”;
cin >> temp;
clrscr();
draw();
}
} while(error != 0);

draw();
error = 0;
}

void compchoice()

}

======