ххх87
15.11.2020 03:50

объясните как работает этот код (только js код) ( js код "Крестики нолики")
const area = document.getElementById('area');
let move = 0;
let result = '';
const contentWrapper = document.getElementById('content');
const overlay = document.getElementById('overlay');
const btnClose = document.getElementById('btn-close');
const modalResult = document.getElementById('modal-result-wrapper');

area.addEventListener('click', e => {
if(e.target.className = 'box') {
if (move % 2 === 0) {
e.target.innerHTML = 'X';
e.target.style.color = 'blue';
e.target.classList.add('disabledbutton');
} else {
e.target.innerHTML = '0';
e.target.classList.add('disabledbutton');
}
move++;
check();
}
});

const check = () => {
const boxes = document.getElementsByClassName('box');
const arr = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[2,4,6]
];
for(i = 0; i < arr.length; i++) {
if (
boxes[arr[i][0]].innerHTML == 'X' && boxes[arr[i][1]].innerHTML == 'X' && boxes[arr[i][2]].innerHTML == 'X'
) {
result = 'крестики';
prepareResult(result);
} else if (
boxes[arr[i][0]].innerHTML == '0' && boxes[arr[i][1]].innerHTML == '0' && boxes[arr[i][2]].innerHTML == '0'
) {
result = 'нолики';
prepareResult(result);
} else if (
move == 9
) {
result = 'ничья';
prepareResultfriendship(result);
}
}
}

const prepareResultfriendship = winner => {
contentWrapper.innerHTML = `У вас ${winner} !`;
modalResult.style.display = 'block';
}

const prepareResult = winner => {
contentWrapper.innerHTML = `Победили ${winner} !`;
modalResult.style.display = 'block';
}

const closeModal = () => {
modalResult.style.display = 'none';
location.reload();
}

overlay.addEventListener('click', closeModal);
btnClose.addEventListener('click', closeModal);

(Код CSS)
/*размер и выравнивание шрифта*/
.content {
text-align: center;
font-size: 33px;
}

/*выстраиваем квадраты по центру*/
.area-wrapper {
display: flex;
justify-content: center;
}

/*настройки квадратов "местоположение, цвет"тд */
#area {
width: 600px;
height: 600px;
background-color: #86a2e1;
display: flex;
flex-wrap: wrap;
}

/*размер квадратов*/
.box {
width: 200px;
height: 200px;
border: 1px solid white;
box-sizing: border-box;
font-size: 75px;
color: brown;
display: flex;
justify-content: center;
align-items: center;
}

/*размер шрифта в конце игры*/
#modal-result-wrapper {
display: none;
font-size: 25px;
}

/*настройки окна в конце игры*/
#modal-window {
height: 200px;
background-color: white;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-flow: column;
justify-content: space-between;
align-items: center;
width: 300px;
padding: 20px;
}

/*настройки кнопки "начать новую игру"*/
#btn-close {
display: flex;
align-items: center;
justify-content: center;
width: 250px;
height: 50px;
background-color: #86a2e1;
color: white;
}

.disabledbutton {
pointer-events: none;
}

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
1234567891155
04.12.2021 03:04
Program yeah;const N=15;const M=15;var A:array [1..N,1..M] of integer;i,j,b,c,x,y:integer;beginrandomize;write('матрица: ');writeln;for i:=1 to N do begin   for j:=1 to M do beginA[i,j]:=random(100);write(A[i,j]:3);end;writeln;end;c:=1;while c<16 do beginfor i:=1 to N do begin   for j:=1 to M do beginb:=A[1,c];end;end;x:=x+b;c:=c+1;end;writeln('сумма первой строчки: ',x);c:=1;while c<16 do beginfor i:=1 to N do begin   for j:=1 to M do beginb:=A[15,c];end;end;y:=y+b;c:=c+1;end;writeln('сумма последней строчки: ',y);x:=x+y;writeln('общая сумма: ',x);end.
0,0(0 оценок)
Ответ:
ALexus67
23.10.2021 17:03
1.
0,5 Кбайт = 0,5*1024 байт = 512*8 бит
512*8/128 = 32

2.
Память для одного символа = log(2)64=6 бит
Объем текста = 10*32*64*6 бит = 10*32*64*6/8 байт =
10*4*64*6/1024 Кбайт = 15 Кбайт

3.
3 Кбайт = 3*1024 байт = 3*1024*8 бит
Память для одного символа = 3*1024*8/6144 = 4 бита
Количество символов в алфавите = 2^4 = 16

4.
Память для одного символа = log(2)128=7 бит
Объем сообщения = 10*7 = 70 бит

8.
a) 3 Кбайт=3*1024 Байт = 3072 бАЙТ
b) 2 Мбайт=2*1024 Кбайт = 2*1024*1024 байт = 2*1024*1024*8 бит = 16777216 бит
c) 4,5 Гигабайт=4,5*1024 Мбайт = 4,5*1024*1024 Кбайт = 4718592 Кбайт
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота