
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
- •Interface
- •Implementation
УО Колледж «Академия Банковского Дела»
Кафедра «Информационные технологии»
Отчет по практике
по дисциплине «Основы алгоритмизации и программирования»
Выполнил: ст. группы 206
Цацин Юрий
Проверил: преподаватель
Конуспаева А.Т.
Алматы 2013
Задача №1
Дана сторона квадрата a. Найти его площадь S = a2.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm3 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label2: TLabel;
Edit2: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var a,s:real;
begin
a:=strtofloat(edit1.Text);
s:=sqr(a);
edit2.Text:=floattostr(s);
end;
end.
Задача №2
Дана масса M в килограммах. Используя операцию деления нацело,
найти количество полных тонн в ней (1 тонна = 1000 кг).
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm3 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Label2: TLabel;
Edit2: TEdit;
procedure Label1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Label1Click(Sender: TObject);
var t,kg:integer;
begin
kg:=strtoint(edit1.Text);
t:=kg div 1000;
edit2.Text:=inttostr(t);
end;
end.
Задача №3
Дано целое число A. Проверить истинность высказывания: «Чис-
ло A является нечетным».
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm3 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Edit2: TEdit;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
Var a: integer;
b:string;
begin
a:=strtoint(edit1.Text);
if a mod 2<>0 then b:= 'число нечетное'else b:='Высказывание не верно';
edit2.Text:=(b);
end;
end.
Задача №4
Дано целое число. Если оно является положительным, то прибавить к нему 1; в противном случае вычесть из него 2. Вывести полученное число.
unit Unit1;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Label2: TLabel;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var a,b:integer;
begin
a:=strtoint(edit1.text);
if a>0 then b:=(a+1) else b:=(a-2);
edit2.Text:=inttostr(b);
end;
end.
Задача№5
Дано целое число K. Вывести строку-описание оценки, соответствую-
щей числу K (1 — «плохо», 2 — «неудовлетворительно», 3 — «удовлетвори- тельно», 4 — «хорошо», 5 — «отлично»). Если K не лежит в диапазоне 1–5, то вывести строку «ошибка».
unit Unit1;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Label2: TLabel;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var x:integer;
begin
x:=strtoint(edit1.Text);
case x of
1:edit2.Text:='Плохо';
2:edit2.Text:='Неудовлитворительно';
3:edit2.Text:='Удовлитворительно';
4:edit2.text:='хорошо';
5:edit2.Text:='отлично';
6:edit2.text:='ошибка';
end;
end;
end.
Задача№6
Даны два целых числа A и B (A < B). Вывести в порядке возрастания все целые числа, расположенные между A и B (включая сами числа A и B), а также количество N этих чисел.
unit Unit1;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Label3: TLabel;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var a,b,n,i:integer;
begin
a:=strtoint(edit1.Text);
b:=strtoint(edit2.Text);
edit3.Text:='';
n:=b-a+1;
for i:=a to b do
edit3.Text:=edit3.Text+inttostr(i)+' ';
end;
end.
Задача№7
Даны положительные числа A и B (A > B). На отрезке длины A раз-
мещено максимально возможное количество отрезков длины B (без нало- жений). Не используя операции умножения и деления, найти количество отрезков B, размещенных на отрезке A.
unit Unit1;
Interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Label3: TLabel;
Edit3: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var a,b,k:integer;
begin
a:=strtoint(edit1.Text);
b:=strtoint(edit2.text);
if b>a then
k:=0
else
begin
k:=0;
while a>b do
begin
a:=a-b;
k:=k+1;
end;
end;
edit3.text:=floattostr(k);
end; end.
Задача№8
Дано целое число N (> 1). Найти наибольшее целое число K, при котором выполняется неравенство 3K < N.
unit zadacha8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
Edit2: TEdit;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
N,k:integer;
begin
n:=strtoint(edit1.Text);
k:=0;
While N>0 do
begin
if (N mod 10) = 2 then K:=k+1;
N:=N div 10;
end;
if k=0 then edit2.Text:='false' else edit2.Text:='true';
end;
end.
Задача№9
Даны десять вещественных чисел. Найти их произведение.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
Label1: TLabel;
StringGrid1: TStringGrid;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var a:array [0..9] of real;
i:integer;
s:real;
begin
S:=1;
for i:=0 to 9 do begin
a[i]:=strtofloat(stringgrid1.cells[i,0]);
s:=s*a[i];
end;
edit1.Text:=floattostr(s);
end;
end.
Задача№10
Даны целые числа K, N и набор из N вещественных чисел: A1,
A2, . . ., AN . Вывести K -e степени чисел из данного набора: (A1)K , (A2)K , . . ., (AN )K .
unit Unit1;