
- •Завдання на курсовий проект (роботу) студенту
- •Календарний план
- •Реферат
- •Введение
- •Постановка задачи
- •Имя: array[1..N, 1..M] of тип;
- •Разработка алгоритма
- •Структура программы
- •Инструкция оператору
- •Перечень ссылок
- •Приложение а.
- •Приложение б текст программы
- •Приложение в результаты выполнения программы
Приложение а.
СХЕМА АЛГОРИТМА ПРОГРАММЫ
Рисунок А.1 – Схема алгоритма procedure TForm1.Button1Click(Sender: TObject)
Рисунок А.2 – Схема алгоритма procedure TForm1.Button2Click(Sender: TObject).
Рисунок А.3 – Схема алгоритма procedure TForm1.Button3Click(Sender: TObject) (1 часть)
Рисунок А.3 – Схема алгоритма procedure TForm1.Button3Click(Sender: TObject) (2 часть)
Рисунок А.3 – Схема алгоритма procedure TForm1.Button3Click(Sender: TObject) (3 часть)
Рисунок А.4 – Схема алгоритма procedure TForm1.Button4Click(Sender: TObject)(1 часть)
Рисунок А.4 – Схема алгоритма procedure TForm1.Button4Click(Sender: TObject)(2 часть)
Рисунок А.5 – Схема алгоритма function TForm1.Check(a,b: integer; M: mas): Boolean.
Рисунок А.6 – Схема алгоритма procedure TForm1.Sort(a,b: integer; var M: mas)
Рисунок А.7 – Схема алгоритма procedure TForm1.Multiply(M,N: mas; var P: mas).
Приложение б текст программы
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LCLType, Forms, Controls, Graphics, Dialogs, StdCtrls,
Grids, ExtCtrls;
const
x = 4;
y = x+1;
z = y+1;
type
mas = array[1..100,1..100] of real;
vector = array[1..100] of real;
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
ListBox1: TListBox;
ListBox2: TListBox;
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
function Check(a,b: integer; M:mas): Boolean;
procedure Sort(a,b: integer; var M:mas);
procedure Multiply(M,N: mas; var P: mas);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
Matrix1, Matrix2, Matrix3: mas;
A,B: vector;
p,q: byte;
i,j,k: integer;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
Button2.Enabled:=true;
for i:=1 to x do
for j:=1 to y do
begin
Matrix1[i,j]:=random(10)+random(10)/10;
StringGrid1.Cells[j-1,i-1]:=FloatToStr(Matrix1[i,j]);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Button3.Enabled:=true;
ListBox1.Clear;
ListBox2.Clear;
Listbox1.Visible:=true;
Listbox2.Visible:=true;
for i:=1 to y do
begin
A[i]:=random(10)+random(10)/10;
ListBox1.Items.Add(FloatToStr(A[i]));
B[i]:=random(10)+random(10)/10;
ListBox2.Items.Add(FloatToStr(B[i]));
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var temp: real;
index: integer;
begin
p:=3;
q:=2;
if ((Edit1.Text<>'') or (Edit2.Text<>'')) then
begin
p:=StrToInt(Edit1.Text);
q:=StrToInt(Edit2.Text);
if (p<1) or (p>x) then p:=random(x)+1;
if (q<1) or (q>y) then q:=random(y)+1;
end;
Edit1.Text:=IntToStr(p);
Edit2.Text:=IntToStr(q);
for i:=1 to x do
for j:=1 to y do
begin
Matrix1[i,j]:=StrToFloat(StringGrid1.Cells[j-1,i-1]);
Matrix2[i,j]:=Matrix1[i,j];
end;
for i:=y downto p+2 do
for j:=1 to z do
begin
temp:=Matrix2[i,j];
Matrix2[i,j]:=Matrix2[i-1,j];
Matrix2[i-1,j]:=temp;
end;
for j:=z downto q+2 do
for i:=1 to y do
begin
temp:=Matrix2[i,j];
Matrix2[i,j]:=Matrix2[i,j-1];
Matrix2[i,j-1]:=temp;
end;
index:=0;
for j:=1 to z do
if j<>q+1 then
begin
inc(index);
Matrix2[p+1,j]:=A[index];
end;
for i:=1 to y do
begin
Matrix2[i,q+1]:=B[i];
for j:=1 to z do
StringGrid2.Cells[j-1,i-1]:=FloatToStr(Matrix2[i,j]);
end;
Button4.Enabled:=true;
end;
procedure TForm1.Button4Click(Sender: TObject);
var condition: boolean;
begin
for i:=1 to y do
for j:=1 to z do
begin
if (i<=x) and (j<=y) then Matrix1[i,j]:=StrToFloat(StringGrid1.Cells[j-1,i-1]);
Matrix2[i,j]:=StrToFloat(StringGrid2.Cells[j-1,i-1]);
end;
condition:=false;
if check(x,y,Matrix1) and check(y,z,Matrix2) then condition:=true;
if condition=true then
begin
sort(x,y,Matrix1);
sort(y,z,Matrix2);
for i:=1 to y do
for j:=1 to z do
begin
if (i<=x) and (j<=y) then StringGrid1.Cells[j-1,i-1]:=FloatToStr(Matrix1[i,j]);
StringGrid2.Cells[j-1,i-1]:=FloatToStr(Matrix2[i,j]);
end;
end
else
begin
multiply(Matrix1, Matrix2, Matrix3);
for i:=1 to x do
for j:=1 to z do
StringGrid3.Cells[j-1,i-1]:=FloatToStr(Matrix3[i,j]);
end;
Application.MessageBox('Работа программы завершена успешно.', 'Info', MB_ICONINFORMATION);
end;
function TForm1.Check(a,b: integer; M: mas): Boolean;
begin
check:=true;
for i:=1 to a do
begin
for j:=1 to b div 2 do
if M[i,j]<>M[i,y-j+1] then check:=false;
if check=true then break;
end;
end;
procedure TForm1.Sort(a,b: integer; var M: mas);
var
p: real;
product: vector;
begin
for i:=1 to a do
begin
p:=0;
for j:=1 to b do p:=p+M[i, j];
product[i]:=p;
end;
for i:=1 to a-1 do
for j:=1 to a-i do
if product[j] < product[j+1] then
begin
p:=product[j];
product[j]:=product[j+1];
product[j+1]:=p;
for k:=1 to b do
begin
p:=M[j,k];
M[j,k]:=M[j+1,k];
M[j+1,k]:=p
end
end;
end;
procedure TForm1.Multiply(M,N: mas; var P: mas);
begin
for i:=1 to x do
for j:=1 to z do
begin
P[i,j]:=0;
for k:=1 to y do
P[i,j]:=P[i,j]+M[i,k]*N[k,j];
end;
end;
end.