мария2382
20.04.2020 22:35

Объясните что за что отвечает в этом коде, а то ничего не понятно :( Uses graphABC,ABCObjects;
var
i,xhead,yhead,z,appleX,appleY:integer;
head:CircleABC;

snake:array[1..4] of CircleABC;
apple:circleABC;
score:TextABC;

procedure keyDown(key:integer);
begin
if(key = vk_Right) then z := 1;
if(key = vk_Left) then z := 2;
if(key = vk_Up) then z := 3;
if(key = vk_Down) then z := 4;
end;

begin

for i:=0 to 6 do
begin
line(0,i*80,windowWidth,i*80);
end;

for i:=0 to 8 do
begin
line(i*80,0,i*80,windowHeight);
end;

xhead := 3*80 - 40;
yhead := 2*80 - 40;

appleX := 6*80 - 40;
appleY := 3*80 - 40;

apple := CircleABC.Create(appleX,appleY,40,clRed);

head := CircleABC.Create(xhead,yhead,40,clBlue);

for i:=1 to 4 do
begin
snake[i] := CircleABC.Create(xhead,yhead+80*i,40,clBlue);
end;

score := TextABC.Create(5,0,80,'0',clGreen);

while(true) do
begin

onKeyDown := keyDown;

if(z <> 0) then
begin
for i:=4 downto 2 do
begin
snake[i].MoveTo(snake[i-1].Position.X,snake[i-1].Position.Y);
end;

snake[1].MoveTo(xhead-40,yhead-40);
end;

if(z = 1) then xhead := xhead + 80
else if (z = 2) then xhead := xhead - 80
else if (z = 3) then yhead := yhead - 80
else if (z = 4) then yhead := yhead + 80;

if(xhead > windowWidth) then xhead := 40;
if(xhead < 0) then xhead := windowWidth - 40;
if(yhead > windowHeight) then yhead := 40;
if(yhead < 0) then yhead := windowHeight - 40;

if((xHead = appleX) and (yHead = appleY)) then
begin

appleX := random(1,8)*80 - 40;
appleY := random(1,6)*80 - 40;
apple.MoveTo(appleX-40,appleY - 40);
score.Text := ((score.Text).ToInteger + 1).ToString();

end;

head.MoveTo(xhead-40,yhead - 40);
sleep(200);
end;

end.

Нажмите на рекламу ниже и сразу увидите ответ
↓
Популярные вопросы:
Ответ:
helpplease14
18.11.2021 15:01
Var dv,tr,pt,dv1,tr1,pt1,dv2,tr2,pt2 :real;

procedure nod( var dv,tr,pt,dv1,tr1,pt1,dv2,tr2,pt2 :real; );
var a:array[1..6] of real;
i : integer;
begin
dv1:=100;
tr1:=100;
pt1:=100;
for i:= low(a) to high (a) do begin
readln(a[i]);
repeat
if( (a[i] mod 2) =0) then begin
a[i]:=a[i]/2;
dv:=dv+1;
end
else if( ( a[i] mod 3)=0) then begin
a[i]:=a[i]/3;
tr:=tr+1;
end
else if ( ( a[i] mod 5)=0) then begin
a[i]:=a[i]/5;
pt:=pt+1;
end;

untill(a=1);
if dvif trif ptdv:=0;
tr:=0;
pt:=0;
end;
if dv1>0 then dv2:=dv1*2 else dv2:=1;
if tr1>0 then tr2:=tr1*3 else tr2:=1;
if pt1>0 then pt2:=pt1*5 else pt2:=1;
nod:=dv2*tr2*pt2;
writeln(nod);
end;
begin
nod( dv,tr,pt,dv1,tr1,pt1,dv2,tr2,pt2 );
end.

end;
0,0(0 оценок)
Ответ:
agexmambo
17.03.2023 02:56
Задача №1
//PascalABC.NET (версия 3.1, сборка 1196 от 09.03.2016)
Var n, i: integer; 
Begin                   
writeln ('Введите число');
readln(n);                                    
writeln('Делители числа:');  
for i := 1 to n div 2 do     
  if (n mod i) = 0 then begin 
    write(i,'  ');
  end;         
End.       

Задача №2 (алгоритм не очень шустрый, но работает и понятный)
//PascalABC.NET (версия 3.1, сборка 1196 от 09.03.2016)
var
  a, b, x, y, nod: integer;

begin
  writeln('Введите a,b');
  readln(a, b);
  x := a;y := b;
  while x <> y do
    if x > y
      then x := x - y
    else y := y - x;
  nod := x;
  writeln('NOD(', a, ',', b, ')=', nod);
end.
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота