/*************************************** * Iks-Oks 1.0 * * Copyright (C)2006 by Vladimir Tomic * * vtomic85@yahoo.com * ***************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include using namespace std; #define DIM 10 // dimenzija table (visina = sirina) #define ROW 5 // broj potrebnih spojenih znakova za pobedu // Ispisivanje table void pisi (char t[DIM][DIM]) { for (int i=0; i<50; i++) cout<<"\n "; for (int i=0; i=0) && (x=0) && (y=0) && (t[i][j]==s)) NS++; i=x; j=y; while ((++i=ROW-1) return true; i=x; j=y; while ((--j>=0) && (t[i][j]==s)) WE++; i=x; j=y; while ((++j=ROW-1) return true; i=x; j=y; while ((--i>=0) && (--j>=0) && (t[i][j]==s)) NWSE++; i=x; j=y; while ((++i=ROW-1) return true; i=x; j=y; while ((--i>=0) && (++j=0) && (t[i][j]==s)) NESW++; if (NESW>=ROW-1) return true; return false; } // Da li je tabla puna? bool tabla_puna (char t[DIM][DIM]) { for (int i=0; i>x>>y; // while (!koord_OK(t,x,y)) { // cout<<"\n*** KOORDINATE VAN OPSEGA ILI ZAUZETO POLJE!!!\n"; // Pocetni potez cout<<"\nUnesite koordinate polja: "; // cin>>x>>y; // } // t[x][y]='X'; // while ((!tabla_puna(t)) && (!pobeda(t,x,y,turn))) { pisi (t); swap (turn); cout<<"\nUnesite koordinate polja: "; cin>>x>>y; while (!koord_OK(t,x,y)) { cout<<"\n*** KOORDINATE VAN OPSEGA ILI ZAUZETO POLJE!!!\n"; cout<<"\nUnesite koordinate polja: "; cin>>x>>y; } t[x][y]=((turn==-1)?'O':'X'); } if (pobeda(t,x,y,turn)) cout<<"\n\nPOBEDNIK JE "<<((turn==1)?'X':'O')<<"!!!\n"; else cout<<"\n\nNERESENO!"; pisi (t); cout<<"\n\n\n"; return 0; }