int [][] numbers = new int[10][10];
int [] result = new int[11];
int pos = 50;
int index = 0;
void setup()
{
background(150,150,150);
size(700,700);
for (int i = 0; i <= 9; i++)
{
result[i] = 0;
}
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 9; j++)
{
numbers[i][j] = int(random(0,9));
fill(255,255,255);
rect(i*50,j*50,50,50);
}
}
}
void draw()
{
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 9; j++)
{
fill(255,255,255);
rect(i*50,j*50,50,50);
textSize(25);
fill(204, 102, 0);
text(numbers[i][j], i*50 + 20, j*50 + 25);
}
}
}
void keyPressed() {
if (keyCode == ENTER){
for (int k = 0; k <= 9; k++)
{
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 9; j++)
{
if (k==numbers[i][j])
{
result[k]+=1;
}
}
}
}
}
String n = "0123456789";
if (pos == 100)
{
background(150,150,150);
text("число ",0,600);
text(index,100,600);
text(" = ",0,600);
text(result[index],200,600);
index = index + 1;
for (int i = 0; i <= 9; i++)
{
result[i] = 0;
}
pos = 50;
}
for (int i = 0; i <= 9;i++)
{
if (keyCode == n.charAt(i))
{
fill(0,0,0);
textSize(25);
text(n.charAt(i),pos,550);
pos += 25;
}
}
}
|