Vous êtes sur la page 1sur 2

#include <winbgim.

h>

#include <iostream>
using namespace std;
void waitForLeftMouseClick();

int main()
{
initwindow(400,300); //open a 400x300 graphics window

// delete these lines and replace them with your own code:
int v[20][20],i,j,a,b;
a=12;
b=12;
int x=100,y=100,k=650,n=100,p=350,h=350;

for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{

if((i==a-1)||(j==b-1)||(i==0)||(j==0))
{
v[i][j]=2;
v[7][4]=3;
v[8][2]=3;
v[9][9]=3;

}
else
{
v[i][j]=1;
}
if((j==b-1))
{
v[i][j]=0;
}

}
for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{

if(v[i][j] == 2)
{
x = x +50;
setcolor(6);
rectangle(x,y,x+50,y+50);

}
if(v[i][j] == 0)
{
k = k +50;
setcolor(6);
rectangle(k,n,k+50,n+50);

}
if(v[i][j] ==3)
{
p = p+50;
setcolor(4);
rectangle(p,h,p+50,h+50);

}
}
y=y+50;
x=100;
n=n+50;
k=650;
p=p+ 5;

}
for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{
cout<<v[i][j]<<" ";
}cout<<endl;
}

// while(!kbhit()); // wait for user to press a key


waitForLeftMouseClick(); // use one or the other of these--not both

closegraph(); //close graphics window


return 0;
}

void waitForLeftMouseClick()
{
clearmouseclick(WM_LBUTTONDOWN);
const int DELAY = 50; // Milliseconds of delay between checks
int x, y;
while (!ismouseclick(WM_LBUTTONDOWN))
delay(DELAY);
getmouseclick(WM_LBUTTONDOWN, x, y);
}

Vous aimerez peut-être aussi