procedure SysX_to_SysY(sysX: string; osnX,osnY: integer; var sysY: string);
var dec,i,z1,z2,r:integer;
b,c:string;
begin
i:=0;
dec:=0; { число в десятичной системе }
sysY:='';
while sysX<>'' do { переводим число из системы Х в десятичную }
begin
c:=copy(sysX,length(sysX),1);
delete(sysX,length(sysX),1);
if i=0 then z2:=1 else z2:=round(exp(i*ln(osnX)));
if ord(c[1]) > 64 then z1:=ord(c[1])-55
else z1:=StrToInt(c);
dec:=dec+z1*z2; inc(i);
end;
while dec > 0 do { переводим число из десятичной системы в ситему Y }
begin
r:=dec mod osnY;
dec:=dec div osnY;
if r < 10 then b:=IntToStr(r) else b:=chr(ord('A')-10+r);
sysY:=b+sysY;
end;
end;
var
number, result: String;
begin
{ Ввод пятиричного числа }
Write('Input number: '); ReadLn(number);
{ Перевод числа }
SysX_to_SysY(number, 5, 14, result);
{ Вывод ответа }
WriteLn('Result = ', result);
end.
unit UMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, jpeg;
type
TMainForm = class(TForm)
Car: TImage;
Block1: TImage;
Block2: TImage;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Bevel3: TBevel;
Timer1: TTimer;
Timer2: TTimer;
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
Bonus:integer;
implementation
{$R *.dfm}
procedure GameOver;
begin
MainForm.Timer1.Enabled:=false;
MainForm.Timer2.Enabled:=false;
ShowMessage('Аварія');
end;
procedure TMainForm.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
//Управление машиной кнопками мышки
If (Button=mbLeft) and (Car.left>0) then
Car.left:=Car.left-(Car.width div 2);
If (Button=mbRight) and (Car.Left<(450-Car.Width)) then
Car.Left:=Car.Left+(Car.Width div 2);
end;
procedure TMainForm.Button2Click(Sender: TObject);
begin
close;
end;
procedure TMainForm.Button1Click(Sender: TObject);
begin
//Располагаем препятсвия
Block1.Left:=128;
Block1.Top:=288;
Block2.Left:=320;
Block2.Top:=50;
Bonus:=0;
Label1.Caption:='0';
//Показываем препятствия
Block1.Show;
Block2.Show;
Car.Show;
//Включаем все таймеры;
Timer1.Enabled:=true;
Timer2.Enabled:=true;
end;
procedure TMainForm.Timer1Timer(Sender: TObject);
begin
//Отображаем очки игрока
Label1.Caption:=IntToStr(Bonus);
//Задаем движение препятствия1
Block1.Top:=Block1.Top+(block1.height div 2);
//Проверяем не произошла ли авария
if (Block1.Top+Block1.Height)>(Car.Top) then
if (Block1.Left+1<=Car.Left) and (Car.Left<=(Block1.Left+Block1.Width-1))
then GameOver;
if (Block1.Top+Block1.Height)>(Car.Top) then
if (Block1.Left+1<=(Car.Left+Car.Width)) and ((Car.Left+Car.Width)<=(Block1.Left+Block1.Width-1))
then GameOver;
//Дошло ли препятствие до нижней границы
If Block1.Top>=(MainForm.ClientHeight) then
begin
Bonus:=Bonus+10;
Block1.Hide;
Block1.Top:=1;
//препятствие не должно вылазить за левую границу
repeat
Block1.Left:=Random(450-Car.Width);
until (Block1.Left>10);
Block1.Show;
end;
end;
procedure TMainForm.Timer2Timer(Sender: TObject);
begin
//Отображаем очки игрока
Label1.Caption:=IntToStr(Bonus);
//Задаем движение препятствия1
Block2.Top:=Block2.Top+(Block2.Height div 2);
//Проверяем не произошла ли авария
if (Block2.Top+Block2.Height)>(Car.Top) then
if (Block2.Left+1<=Car.Left) and (Car.Left<=(Block2.Left+Block2.Width-1))
then GameOver;
if (Block2.Top+Block2.Height)>(Car.Top) then
if (Block2.Left+1<=(Car.Left+Car.Width)) and ((Car.Left+Car.Width)<=(Block2.Left+Block2.Width-1))
then GameOver;
//Дошло ли препятствие до нижней границы
If Block2.Top>=(MainForm.ClientHeight) then
begin
Bonus:=Bonus+10;
Block2.Hide;
Block2.Top:=1;
//препятствие не должно вылазить за левую границу
repeat
Block2.Left:=Random(450-Car.Width);
until (Block2.Left>10);
Block2.Show;
end;
end;
end.
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.