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
|
/*
Name:Ticktacktoe v4
Copyright:
Author:
Date: 25.06.13 16:25
Description:
*/
#include <iostream>
#include <string>
using namespace std;
int sinir, oyun=1;
int ticktacktoe(char a, char b, char c, char d, char e, char f, char g, char h, char i, string oyuncu, int tur)
{ int x;
if(sinir<10){
cout<<"|------TickTackToe------|"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-----------| "<<a<<" | "<<b<<" | "<<c<<" |"<<endl;
cout<<"|-OYUN------|---|---|---|"<<endl;
cout<<"|-"<<oyun<<"/"<<sinir<<"-------| "<<d<<" | "<<e<<" | "<<f<<" |"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-"<<tur<<".TUR-----| "<<g<<" | "<<h<<" | "<<i<<" |"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-----------------------|"<<endl;
cout<<oyuncu<<"'nin sirasi:";}
if(sinir>=10){
cout<<"|------TickTackToe------|"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-----------| "<<a<<" | "<<b<<" | "<<c<<" |"<<endl;
cout<<"|-OYUN------|---|---|---|"<<endl;
cout<<"|-"<<oyun<<"/"<<sinir<<"------| "<<d<<" | "<<e<<" | "<<f<<" |"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-"<<tur<<".TUR-----| "<<g<<" | "<<h<<" | "<<i<<" |"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-----------------------|"<<endl;
cout<<oyuncu<<"'nin sirasi:";}
if(oyun>=10){
cout<<"|------TickTackToe------|"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-----------| "<<a<<" | "<<b<<" | "<<c<<" |"<<endl;
cout<<"|-OYUN------|---|---|---|"<<endl;
cout<<"|-"<<oyun<<"/"<<sinir<<"------| "<<d<<" | "<<e<<" | "<<f<<" |"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-"<<tur<<".TUR-----| "<<g<<" | "<<h<<" | "<<i<<" |"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-----------------------|"<<endl;
cout<<oyuncu<<"'nin sirasi:";}
if(oyun>=10&&sinir>=10){
cout<<"|------TickTackToe------|"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-----------| "<<a<<" | "<<b<<" | "<<c<<" |"<<endl;
cout<<"|-OYUN------|---|---|---|"<<endl;
cout<<"|-"<<oyun<<"/"<<sinir<<"-----| "<<d<<" | "<<e<<" | "<<f<<" |"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-"<<tur<<".TUR-----| "<<g<<" | "<<h<<" | "<<i<<" |"<<endl;
cout<<"|-----------|---|---|---|"<<endl;
cout<<"|-----------------------|"<<endl;
cout<<oyuncu<<"'nin sirasi:";}
cin>>x;
cout<<"\n\n";
return x;
}
int main(){
int puan1=0, puan2=0 , birinci, ikinci;
string oyuncu1, oyuncu2;
cout<<"1.oyuncunun adini giriniz:";
cin>>oyuncu1;
cout<<"2.oyuncunun adini giriniz:";
cin>>oyuncu2;
cout<<"Oynamak istediginiz oyun sayisini girin:";
cin >>sinir;
while (oyun<=sinir){
char a=49;
char b=50;
char c=51;
char d=52;
char e=53;
char f=54;
char g=55;
char h=56;
char i=57;
if(oyun==1) {cout<<"TickTackToe'ye baslamak icin bir tusa basin.\n";}
else {cout<<oyun<<". oyuna baslamak icin bir tusa basin";}
cin.ignore();
cin.get();
for(int tur=1; tur<10; ++tur){
while(1){
birinci=ticktacktoe(a,b,c,d,e,f,g,h,i,oyuncu1,tur);
if(birinci==1&&a!=79&&a!=88) {a=88;++tur;break;}
else if(birinci==2&&b!=79&&b!=88) {b=88;++tur;break;}
else if(birinci==3&&c!=79&&c!=88) {c=88;++tur;break;}
else if(birinci==4&&d!=79&&d!=88) {d=88;++tur;break;}
else if(birinci==5&&e!=79&&e!=88) {e=88;++tur;break;}
else if(birinci==6&&f!=79&&f!=88) {f=88;++tur;break;}
else if(birinci==7&&g!=79&&g!=88) {g=88;++tur;break;}
else if(birinci==8&&h!=79&&h!=88) {h=88;++tur;break;}
else if(birinci==9&&i!=79&&i!=88) {i=88;++tur;break;}
else {cout<<"Hatali giris yaptiniz.\n";continue;}
}
if(a==88&&b==88&&c==88) {++puan1;break;}
else if(d==88&&e==88&&f==88) {++puan1;break;}
else if(g==88&&h==88&&i==88) {++puan1;break;}
else if(a==88&&d==88&&g==88) {++puan1;break;}
else if(b==88&&e==88&&h==88) {++puan1;break;}
else if(c==88&&f==88&&i==88) {++puan1;break;}
else if(a==88&&e==88&&i==88) {++puan1;break;}
else if(g==88&&e==88&&c==88) {++puan1;break;}
if(tur==10){break;}
while(1){
ikinci=ticktacktoe(a,b,c,d,e,f,g,h,i,oyuncu2,tur);
if(ikinci==1&&a!=79&&a!=88) {a=79;break;}
else if(ikinci==2&&b!=79&&b!=88) {b=79;break;}
else if(ikinci==3&&c!=79&&c!=88) {c=79;break;}
else if(ikinci==4&&d!=79&&d!=88) {d=79;break;}
else if(ikinci==5&&e!=79&&e!=88) {e=79;break;}
else if(ikinci==6&&f!=79&&f!=88) {f=79;break;}
else if(ikinci==7&&g!=79&&g!=88) {g=79;break;}
else if(ikinci==8&&h!=79&&h!=88) {h=79;break;}
else if(ikinci==9&&i!=79&&i!=88) {i=79;break;}
else {cout<<"Hatali giris yaptiniz.\n";continue;}
}
if(a==79&&b==79&&c==79) {++puan2;break;}
else if(d==79&&e==79&&f==79) {++puan2;break;}
else if(g==79&&h==79&&i==79) {++puan2;break;}
else if(a==79&&d==79&&g==79) {++puan2;break;}
else if(b==79&&e==79&&h==79) {++puan2;break;}
else if(c==79&&f==79&&i==79) {++puan2;break;}
else if(a==79&&e==79&&i==79) {++puan2;break;}
else if(g==79&&e==79&&c==79) {++puan2;break;}
}
cout<<oyuncu1<<":"<<puan1<<endl;
cout<<oyuncu2<<":"<<puan2<<endl;
++oyun;
}
if(puan1>puan2) {cout<<oyuncu1<<" kazandi.\n";}
else if(puan2>puan1) {cout<<oyuncu2<<" kazandi.\n";}
else if(puan1==puan2) {cout<<"Berabere.\n";}
cin.ignore();
cin.get();
}
|