السلام عليكم ورحمة الله
إخواني الأعزاء آنا سويت بروقرم بالبورلاند حق لعبة الاكس والاو والحمد لله ظبط معاي بس ابغى منكم مساعده بسيطه فيه وهو
إن الكمبيوتر في اللعبه مش ذكي يعني ابغاه يكون ذكي في اللعبه وثاني شي ابغاه يوم مايفوز ولاحد يقول لهم
sorry nobody won,,,
وفي آخر القيم ابغى يوم يضغطون على exit
enter
يصير لهم
exit
من اللعبه
ورجاااء ساعدووني اليوم لانه مطلوب غدا ولكم كل الشكر والتقدير
وهذا هو الكود
#include <iostream.h>
char numbers[]={'1','2','3','4','5','6','7','8','9'};
int choice,o;
void display (){
cout<<endl<<"_________________"<<endl;
for (int n=0;n<9;n++){
cout<<"| "<< numbers[n]<<" | ";
if (n==2 || n==5)
cout<<endl<<"_________________"<<endl;
}// end of n
cout<<endl<<"_________________"<<endl;
}// end of display
void choose(){
cout<<"enter your choise"<<endl;
cin>>choice;
if (choice > 9)
cout<<endl<<"sorry try again";
else if(numbers[choice-1]!='x'&& numbers[choice-1]!='o')
numbers[choice-1]='x';
else
cout<<"Sorry "<<choice<<" is used "<<endl<<endl;
}// end of choice
int winnerX(){
if((numbers[0]=='x' && numbers[1]=='x' && numbers[2]=='x')||
(numbers[3]=='x' && numbers[4]=='x' && numbers[5]=='x')||
(numbers[6]=='x' && numbers[7]=='x' && numbers[8]=='x'))
{
cout<<endl<<" ** you win **"<<endl;
return 0;
}
else if ((numbers[0]=='x'&& numbers[3]=='x' && numbers[6]=='x')||
(numbers[1]=='x'&& numbers[4]=='x' && numbers[7]=='x')||
(numbers[2]=='x'&& numbers[5]=='x' && numbers[8]=='x')){
cout<<endl<<" ** you win **"<<endl;
return 0;
}
else if ((numbers[0]=='x'&& numbers[4]=='x' && numbers[8]=='x')||
(numbers[2]=='x'&& numbers[4]=='x' && numbers[6]=='x')){
cout<<endl<<" ** you win **"<<endl;
return 0;
}
}
void Movment(){
do{
o=rand()%9;
}while (numbers[o]=='x'|| numbers[o]=='o');
numbers[o]='o';
}
void main()
{
int i=1;
do{
display();
choose();
Movment();
winnerX();
}while(winnerX()!=0);
display();
}
#include <stdlib.h>
وشكرا لكم وبانتظاركم