Основы информатики/ Савельев А.Я. , МГТУ им. Баумана. — КиберПедия 

Механическое удерживание земляных масс: Механическое удерживание земляных масс на склоне обеспечивают контрфорсными сооружениями различных конструкций...

История создания датчика движения: Первый прибор для обнаружения движения был изобретен немецким физиком Генрихом Герцем...

Основы информатики/ Савельев А.Я. , МГТУ им. Баумана.

2021-06-02 29
Основы информатики/ Савельев А.Я. , МГТУ им. Баумана. 0.00 из 5.00 0 оценок
Заказать работу

4. Архангельский, Алексей Яковлевич. Delphi 7: справочное пособие / А. Я. Архангельский. - Москва: БИНОМ-ПРЕСС, 2003. – 1024c.

5. Бобровский, Сергей Игоревич. Delphi 7: учебный курс / С. И. Бобровский. - Санкт-Петербург; Москва; Минск: Питер, 2005. - 736 с.


 

ПРИЛОЖЕНИЕ А

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls, Math, Menus;

type

TForm1 = class(TForm)

RadioButton1: TRadioButton;

RadioButton2: TRadioButton;

RadioGroup1: TRadioGroup;

Edit1: TEdit;

Edit2: TEdit;

Label2: TLabel;

Edit3: TEdit;

Label4: TLabel;

Label1: TLabel;

MainMenu1: TMainMenu;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

procedure RadioButton2Click(Sender: TObject);

procedure RadioButton1Click(Sender: TObject);

procedure Edit1Change(Sender: TObject);

procedure Edit2Change(Sender: TObject);

procedure calculations;

procedure RadioGroup1Click(Sender: TObject);

procedure N3Click(Sender: TObject);

procedure N2Click(Sender: TObject);

procedure N4Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

calc_stopper: Boolean=False;

null_stopper: Boolean=false;

minus_stopper: Boolean=false;

negative_counter: Boolean=false;

wrong_numbers: Boolean=False;

implementation

function tentoeight (v:real): Real;

var

i,j,w:Integer;

a:array[1..1000000] of byte;

  negative_sign:Boolean;

begin

   negative_sign:=False;

   i:=0;

   Result:=0;

   if v<0 then begin

     negative_sign:=True;

     v:=v*(-1);

   end;

     w:=Round(v);

     While w>0 do

       begin

         inc(i);

         a[i]:=w mod 8;

         w:=w div 8

       end;

     for j:=i downto 1 do

     Result:=Result+(a[j]*Round(power(10,j)/10));

     if negative_sign=True then Result:=Result*(-1);

end;

function eighttoten (st:string): string;

var

i,v,summ:integer;

a:array[1..1000000] of byte;

negative_sign:Boolean;

begin

   negative_sign:=False;

   summ:=0;

   if st[1]='-' then

     begin

     negative_sign:=True;

     st:=FloatToStr(StrToFloat(st)*(-1));

     end;

v:=length(st);

for i:=1 to v do

   a[v-i+1]:=StrToInt(st[v-i+1]);

for i:=1 to v do

   summ:=summ+Round(Power(8,i-1))*a[v-i+1];

   if negative_sign=False then Result:=IntToStr(summ)

   else begin

     result:=FloatToStr(summ*(-1));

   end;

end;

{$R *.dfm}

procedure TForm1.RadioButton2Click(Sender: TObject);

begin

calc_stopper:=True;

Edit1.Text:=FloatToStr(tentoeight(StrToFloat(Edit1.Text)));

Edit2.Text:=FloatToStr(tentoeight(StrToFloat(Edit2.Text)));

Edit3.Text:=FloatToStr(tentoeight(StrToFloat(Edit3.Text)));

calc_stopper:=false;

end;

procedure TForm1.RadioButton1Click(Sender: TObject);

begin

calc_stopper:=True;

Edit1.Text:=eighttoten(Edit1.Text);

Edit2.Text:=eighttoten(Edit2.Text);

if Label4.Visible=true then

begin wrong_numbers:=False; calc_stopper:=False; calculations; end

else

Edit3.Text:=eighttoten(Edit3.Text);

calc_stopper:=false;

if RadioGroup1.Itemindex=3 then calculations;

end;

procedure TForm1.calculations;

var i:Integer;

begin

Label4.Visible:=False;

if (Edit1.Text='-') or (Edit2.Text='-') or (Edit1.Text='') or (Edit2.Text='') then minus_stopper:=True;

// if (Edit2.Text='0') and (RadioGroup1.Itemindex=3) then null_stopper:=True;

if (RadioButton2.Checked=true) then

begin

for i:=1 to Length(Edit1.Text) do

   if (Edit1.Text[i]='8') or (Edit1.Text[i]='9') then

     wrong_numbers:=True;

for i:=1 to Length(Edit2.Text) do

   if (Edit2.Text[i]='8') or (Edit2.Text[i]='9') then

     wrong_numbers:=True;

end;

if (calc_stopper=False) and (null_stopper=False) and (minus_stopper=False) and (wrong_numbers=False) then

begin

if RadioButton1.Checked=true then

case RadioGroup1.Itemindex of

0: Edit3.Text:=FloatToStr((StrToFloat(Edit1.Text)+StrToFloat(Edit2.Text)));

1: Edit3.Text:=FloatToStr((StrToFloat(Edit1.Text)-StrToFloat(Edit2.Text)));

2: Edit3.Text:=FloatToStr((StrToFloat(Edit1.Text)*StrToFloat(Edit2.Text)));

// 3: Edit3.Text:=FloatToStr((StrToFloat(Edit1.Text)/StrToFloat(Edit2.Text)));

end

else

case RadioGroup1.Itemindex of

0: Edit3.Text:=FloatToStr(tentoeight((StrToFloat(eighttoten(Edit1.Text))+StrToFloat(eighttoten(Edit2.Text)))));

1: Edit3.Text:=FloatToStr(tentoeight((StrToFloat(eighttoten(Edit1.Text))-StrToFloat(eighttoten(Edit2.Text)))));

2: Edit3.Text:=FloatToStr(tentoeight((StrToFloat(eighttoten(Edit1.Text))*StrToFloat(eighttoten(Edit2.Text)))));

// 3: Edit3.Text:=FloatToStr(tentoeight((StrToFloat(eighttoten(Edit1.Text))/StrToFloat(eighttoten(Edit2.Text)))));

end;

end;

// if null_stopper=True then begin Label3.Visible:=True; null_stopper:=False; end;

if minus_stopper=True then minus_stopper:=False;

if wrong_numbers=True then begin Label4.Visible:=True; wrong_numbers:=False; end;

end;

procedure TForm1.Edit1Change(Sender: TObject);

begin

calculations;

end;

procedure TForm1.Edit2Change(Sender: TObject);

begin

calculations;

end;

procedure TForm1.RadioGroup1Click(Sender: TObject);

begin

case RadioGroup1.ItemIndex of

0: Label1.Caption:='+';

1: Label1.Caption:='-';

2: Label1.Caption:='*';

3: Label1.Caption:='/';

end;

calculations;

end;

procedure TForm1.N3Click(Sender: TObject);

begn

Edit1.Text:='0';

Edit2.Text:='0';

calc_stopper:=false;

end;

procedure TForm1.N2Click(Sender: TObject);

begin

MessageDlg('Восьмеричный калькулятор. Автор Кондратьев Денис.',mtWarning,[mbOK],0);

end;

procedure TForm1.N4Click(Sender: TObject);

begin

Form1.Close;

end;

end.

 


Поделиться с друзьями:

История развития хранилищ для нефти: Первые склады нефти появились в XVII веке. Они представляли собой землянные ямы-амбара глубиной 4…5 м...

Типы сооружений для обработки осадков: Септиками называются сооружения, в которых одновременно происходят осветление сточной жидкости...

Архитектура электронного правительства: Единая архитектура – это методологический подход при создании системы управления государства, который строится...

Археология об основании Рима: Новые раскопки проясняют и такой острый дискуссионный вопрос, как дата самого возникновения Рима...



© cyberpedia.su 2017-2024 - Не является автором материалов. Исключительное право сохранено за автором текста.
Если вы не хотите, чтобы данный материал был у нас на сайте, перейдите по ссылке: Нарушение авторских прав. Мы поможем в написании вашей работы!

0.009 с.