int arraystate[][] = new int[6][4];
int arraynumber[][] = new int[6][4];
int number_pos_1 = -1;
int number_pos_2 = -1;
int number_pos_3 = -1;
int number_pos_4 = -1;
int numberValue_1 = 0;
int numberValue_2 = 0;
int click = 0;
void setup()
{
size(700,700);
background(122,122,122);
for (int i = 0;i < 6;i++)
{
for (int z = 0;z < 4;z++)
{
arraystate[i][z] = 0;
arraynumber[i][z] = 0;
rect(i*50,z*50,50,50);
}
}
int number = 0;
//формирование одинаковых пар чисел
for (int i = 0;i < 6; i++)
{
number++;
for (int j = 0;j < 4; j++)
{
if (i%2 == 0 && j%2 == 0)
{
arraynumber[i][j] = number;
}
if (i%2+1!= 0 && j%2+1 != 0)
{
arraynumber[i][j] = number;
}
}
}
for (int i = 0;i < 6; i++)
{
for (int j = 0;j < 4; j++)
{
int index1 = (int)random(0,6);
int index2 = (int)random(0,4);
//обмен значений
number = arraynumber[i][j];
arraynumber[i][j] = arraynumber[index1][index2];
arraynumber[index1][index2] = number;
}
}
}
void draw(){
}
void mouseClicked() {
background(122,122,122);
for (int i = 0;i < 6;i++)
{
for (int z = 0;z < 4;z++)
{
fill(255.255,255);
rect(i*50,z*50,50,50);
}
}
for (int i = 0;i < 6;i++)
{
for (int z = 0;z < 4;z++)
{
if (mouseX > i*50 && mouseX < i*50+50 && (mouseY > z*50 && mouseY<z*50+50) )
{
click++;
if (click == 1){
number_pos_1 = i;
number_pos_2 = z;
numberValue_1 = arraynumber[i][z];
}
if (click == 2){
number_pos_3 = i;
number_pos_4 = z;
numberValue_2 = arraynumber[i][z];
click = 0;
}
if ((number_pos_1 == number_pos_3) && number_pos_2 ==number_pos_4)
{
println("та же самая клетка");
}
else{
if (numberValue_1 == numberValue_2){
println("Разные клетки с одинаковыми значениями");
}
}
textSize(25);
fill(0,255,0);
text(arraynumber[i][z],i*50+15, z*50+25);
}
}
}
for (int i = 0;i < 6;i++)
{
for (int z = 0;z < 4;z++)
{
textSize(25);
fill(0,255,0);
text(arraynumber[i][z],i*50+15, z*50+325);
if (arraystate[i][z] == 1)
text(arraynumber[i][z],i*50+15, z*50+25);
}
}
}
|