98 lines
1.3 KiB
C
98 lines
1.3 KiB
C
|
#include <stdlib.h>
|
||
|
#include <graph.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
void Croix(int c,int l)
|
||
|
{
|
||
|
DessinerSegment(20+300*c,20+300*l,280+300*c,280+300*l);
|
||
|
DessinerSegment(280+300*c,20+300*l,20+300*c,280+300*l);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
void Cercle(int c, int l)
|
||
|
{
|
||
|
DessinerArc(300*c+20,300*l+20,260,260,0,360);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
int victoire(int tab[3][3])
|
||
|
{
|
||
|
int full=0;
|
||
|
for(int i=0;i<3;i++)
|
||
|
{
|
||
|
for(int j=0;j<3;j++)
|
||
|
if (tab[i][j]==0)
|
||
|
{
|
||
|
full++;
|
||
|
}
|
||
|
}
|
||
|
for(int i=0;i<3;i++)
|
||
|
{
|
||
|
if (tab[i][0]==tab[i][1]&&tab[i][1]==tab[i][2])
|
||
|
{
|
||
|
if (tab[i][0]!=0)
|
||
|
{
|
||
|
return(1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if (full==9)
|
||
|
{
|
||
|
return(-1);
|
||
|
}
|
||
|
else{return(0);}
|
||
|
}
|
||
|
|
||
|
int main(int argc, char const *argv[])
|
||
|
{
|
||
|
int x=_X;
|
||
|
int y=_Y;
|
||
|
|
||
|
InitialiserGraphique();
|
||
|
CreerFenetre(10,10,900,900);
|
||
|
DessinerSegment(300,0,300,900);
|
||
|
DessinerSegment(600,0,600,900);
|
||
|
DessinerSegment(0,300,900,300);
|
||
|
DessinerSegment(0,600,900,600);
|
||
|
int l,c;
|
||
|
int tab[3][3]={0};
|
||
|
int tour=1;
|
||
|
int vic=0;
|
||
|
while(vic==0)
|
||
|
{
|
||
|
while(!SourisCliquee());
|
||
|
l=_Y/300;
|
||
|
c=_X/300;
|
||
|
if (tab[c][l]==0)
|
||
|
{
|
||
|
if ((tour%2)==0)
|
||
|
{
|
||
|
Croix(c,l);
|
||
|
tab[c][l]=1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Cercle(c,l);
|
||
|
tab[c][l]=2;
|
||
|
}
|
||
|
tour++;
|
||
|
}
|
||
|
vic=victoire(tab);
|
||
|
}
|
||
|
|
||
|
if (vic==-1)
|
||
|
{
|
||
|
printf("Egalité !");
|
||
|
}
|
||
|
if (vic=1&&(tour%2)==0)
|
||
|
{
|
||
|
printf("Victoire Croix !");
|
||
|
}else{
|
||
|
printf("Victoire Cercle !");
|
||
|
}
|
||
|
|
||
|
|
||
|
Touche();
|
||
|
FermerGraphique();
|
||
|
return 0;
|
||
|
}
|