Реферат Курсовая Конспект
Описание работы программы - раздел Информатика, Цель:Приобретение И Закрепление Знаний И Получение Практичес...
|
Цель:Приобретение и закрепление знаний и получение практических навыков работы с простейшей нейронной сетью, разработанной Розенблаттом.
Описание работы программы.
Данная программа является примитивным перцептроном Розенблатта, распознающим любые два символа, изображение которых можно ввести при помощи матрицы размером 4´4.
Для примера рассмотрим значение букв «Н» и «С».
Для запуска программы необходимо запустить файл Perzep.exe. после чего вы получите:
В левом верхнем углу находятся две таблички в которые вводятся два символа. По умолчанию они установлены в символы «Н» и «С»:
Значения в каждой ячейке таблиц меняются при нажатии на них мышкой с 0 в 1 или наоборот, в зависимости от исходного значения. Таким образом, возможно изменение символов на любые другие:
Активность точек под буквами определяет при обучении и распознании значение символа выше или ниже порога. Если точка под символом активна, то значения символа рассчитывается ниже порога.
Для начала необходимо обучить систему распознавать введенные нами символы. Для этого необходимо нажать клавишу , находящуюся под символами. После её нажатия станут активными кнопки и , находящиеся в правом верхнем углу окна.
Кнопка позволяет заполнить таблицу весов связей перцептрона случайными числами. При повторном нажатии кнопки значения в таблице изменятся. Таким образом можно подобрать таблицу наиболее подходящих значений.
После нажатия на кнопку активизируется кнопка , которая позволяет сохранить значения таблицы в файл.
Внимание! Сохранение выполняется поверх уже имеющегося, следовательно старые значения пропадут. Если их желательно сохранить, тогда необходимо пересохранить файл rand.dat и при необходимости использования переписать в каталог программы.
Загрузить ранее сохранённую таблицу можно с помощью кнопки .
Для данного примера (буквы «Н» и «С») уже подобрана и сохранена таблица весов связей перцептрона:
Вместе с таблицей весов связей перцептрона заполняется ещё таблица величин сигналов на входах:
Значения этой таблицы напрямую зависят от введённых символов и от значений таблицы весов связей перцептрона. Поэтому необходимо подбирать последнюю для получения наилучшего результата величин сигнала на входах. А результат должен быть таким:
1. хотя бы одно значение в столбце матрицы должно быть больше либо равно значению порога («среднее по всей таблице» под таблицей величин сигналов на входах).
2. области выше порога для разных символов должны пересекаться как можно меньше раз.
Например:
В полученной нами таблице величин сигналов на входах хотя бы одно значение столбца выше (либо равно) значения порога и области выше порога пересекаются только в одном месте (UA4):
где - значение, входящее в область значений, которые выше порога.
При подборе таблицы весов связей перцептрона для других символов, необходимо придерживаться того же принципа, что резко повысит качество распознания перцептроном заданных символов.
После вычисления вышеуказанных таблиц становятся доступными кнопки и , которые активизируют работу адаптации весов связей перцептрона с помощью альфа и гамма систем подкрепления соответственно.
При нажатии на кнопку получим:
Система подкрепления даёт нам порог в соответствии с которым есть возможность распознавать символы. Как видно из таблицы значение по первому символу (U1) ниже порога, а значение по второму (U2) – выше.
Далее можно распознавать символ с помощью альфа коррекции, введя его в
таблицу внизу окна и нажав кнопку , находящуюся слева от таблицы получим результат:
Если ввести другой символ , то результат будет такой:
Для проведения распознания символа с помощью гамма коррекции необходимо нажать кнопку , и получаем:
Гамма система подкрепления также даёт нам порог, в соответствии с которым есть возможность распознавать символы. Как видно из таблицы значение по первому символу (U1) ниже порога, а значение по второму (U2) – выше (что задано точками под символами в левом верхнем углу формы).
Далее можно распознавать символ с помощью гамма коррекции, введя его в таблицу внизу окна и нажав кнопку , находящуюся справа от таблицы получим результат:
Если ввести другой символ , то результат будет такой:
Но, как было сказано в начале описания, есть возможность менять положение значений символа относительно порога. До сих пор рассматривалась ситуация, когда значение первого символа было ниже порога, а второго – выше. Теперь рассмотрим обратную ситуацию.
Для этого необходимо активизировать точку под вторым символом:
Значения таблиц весов связей перцептрона и величин сигналов на входах остаются неизменными, а вот альфа и гамма подкреплений должны значительно измениться.
Нажмём и увидим:
Как видно из таблицы значение по первому символу (U1) стало выше порога, а значение по второму (U2) – ниже, что привело к большому количеству вычислений, и вектор t0 претерпел значительные изменения. Что однако не повлияло на качество распознания символов:
Нажав кнопку , находящуюся слева от таблицы получим результат:
То же самое и со вторым символом:
Результат:
Логично предположить, что гамма коррекция тоже претерпела некоторые изменения. Проверим это.
Нажмём кнопку , и получаем:
Как видно здесь значения так же изменились: по первому символу (U1) значение стало выше порога, а по второму (U2) – ниже, что привело к большому количеству вычислений, и вектор t0 так же изменился. Количество вычислений настолько увеличилось, что пришлось задействовать полосу прокрутки, но это отразилось на качестве распознания символов:
Далее можно убедится в правильности распознания символов:
Нажав кнопку , находящуюся справа от таблицы получим результат:
Если ввести другой символ , то:
Внешний вид программы после заполнения всех таблиц:
Завершить работу с программой модно нажав кнопку:
При повторном запуске программы все значения будут обнулены т.к. при её закрытии возможно сохранение только таблицы весов связей перцептрона между S- и А- элементами.
Текст программы:
program Perzep;
uses
Forms,
Unit1 in '..Unit1.pas' {Form1};
{$R *.res}
begin
AssignFile(f,'Rand.dat'); //реквизиты потребителей
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, Buttons;
type
mas=array[0..15]of byte;
rr=array[0..5] of real;
u=array[0..5]of real;
save=array [0..15,0..5]of real;
TForm1 = class(TForm)
StringGrid1: TStringGrid;
BitBtn1: TBitBtn;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
BitBtn2: TBitBtn;
StringGrid4: TStringGrid;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
BitBtn5: TBitBtn;
Label6: TLabel;
Label7: TLabel;
StringGrid5: TStringGrid;
Label8: TLabel;
BitBtn6: TBitBtn;
Label9: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
StringGrid6: TStringGrid;
BitBtn7: TBitBtn;
Label10: TLabel;
StringGrid7: TStringGrid;
BitBtn8: TBitBtn;
Label11: TLabel;
BitBtn9: TBitBtn;
Procedure load;
Procedure Summir;
procedure FormActivate(Sender: TObject);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure StringGrid1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure StringGrid2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure BitBtn7Click(Sender: TObject);
procedure BitBtn8Click(Sender: TObject);
procedure StringGrid7MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure StringGrid7SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure BitBtn9Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x_kurs,y_kurs:integer;
ferst,second,rasp,rasp_g:mas;
u_ferst,u_second,u_rasp,u_rasp_g:u;
rand:save;
f:file of save;
por1,por_al:real;
r,r_e,rg:rr;
implementation
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
//Первая буква
StringGrid1.Cells[0,0]:='1';
StringGrid1.Cells[1,0]:='0';
StringGrid1.Cells[2,0]:='0';
StringGrid1.Cells[3,0]:='1';
StringGrid1.Cells[0,1]:='1';
StringGrid1.Cells[1,1]:='0';
StringGrid1.Cells[2,1]:='0';
StringGrid1.Cells[3,1]:='1';
StringGrid1.Cells[0,2]:='1';
StringGrid1.Cells[1,2]:='1';
StringGrid1.Cells[2,2]:='1';
StringGrid1.Cells[3,2]:='1';
StringGrid1.Cells[0,3]:='1';
StringGrid1.Cells[1,3]:='0';
StringGrid1.Cells[2,3]:='0';
StringGrid1.Cells[3,3]:='1';
//Вторая буква
StringGrid2.Cells[0,0]:='1';
StringGrid2.Cells[1,0]:='1';
StringGrid2.Cells[2,0]:='1';
StringGrid2.Cells[3,0]:='1';
StringGrid2.Cells[0,1]:='1';
StringGrid2.Cells[1,1]:='0';
StringGrid2.Cells[2,1]:='0';
StringGrid2.Cells[3,1]:='0';
StringGrid2.Cells[0,2]:='1';
StringGrid2.Cells[1,2]:='0';
StringGrid2.Cells[2,2]:='0';
StringGrid2.Cells[3,2]:='0';
StringGrid2.Cells[0,3]:='1';
StringGrid2.Cells[1,3]:='1';
StringGrid2.Cells[2,3]:='1';
StringGrid2.Cells[3,3]:='1';
//Распознаваемая буква
StringGrid7.Cells[0,0]:='1';
StringGrid7.Cells[1,0]:='0';
StringGrid7.Cells[2,0]:='0';
StringGrid7.Cells[3,0]:='1';
StringGrid7.Cells[0,1]:='1';
StringGrid7.Cells[1,1]:='0';
StringGrid7.Cells[2,1]:='0';
StringGrid7.Cells[3,1]:='1';
StringGrid7.Cells[0,2]:='1';
StringGrid7.Cells[1,2]:='1';
StringGrid7.Cells[2,2]:='1';
StringGrid7.Cells[3,2]:='1';
StringGrid7.Cells[0,3]:='1';
StringGrid7.Cells[1,3]:='0';
StringGrid7.Cells[2,3]:='0';
StringGrid7.Cells[3,3]:='1';
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
x_kurs:=ACol;
y_kurs:=ARow;
end;
procedure TForm1.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if StringGrid1.Cells[x_kurs,y_kurs]='1' then
StringGrid1.Cells[x_kurs,y_kurs]:='0'
else
StringGrid1.Cells[x_kurs,y_kurs]:='1';
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
i,j,k,m:byte;
a:integer;
begin
BitBtn2.Enabled:=true;
BitBtn5.Enabled:=true;
k:=0;
for i:=0 to 3 do
for j:=0 to 3 do
begin
val(StringGrid1.Cells[j,i],m,a);
ferst[k]:=m;
val(StringGrid2.Cells[j,i],m,a);
second[k]:=m;
inc(k);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
r_e[0]:=0.5;
r_e[1]:=0.8;
r_e[2]:=0.3;
r_e[3]:=0.6;
r_e[4]:=0.7;
r_e[5]:=0.5;
StringGrid3.Cells[0,0]:='';
StringGrid3.Cells[1,0]:='S1';
StringGrid3.Cells[2,0]:='S2';
StringGrid3.Cells[3,0]:='S3';
StringGrid3.Cells[4,0]:='S4';
StringGrid3.Cells[5,0]:='S5';
StringGrid3.Cells[6,0]:='S6';
StringGrid3.Cells[7,0]:='S7';
StringGrid3.Cells[8,0]:='S8';
StringGrid3.Cells[9,0]:='S9';
StringGrid3.Cells[10,0]:='S10';
StringGrid3.Cells[11,0]:='S11';
StringGrid3.Cells[12,0]:='S12';
StringGrid3.Cells[13,0]:='S13';
StringGrid3.Cells[14,0]:='S14';
StringGrid3.Cells[15,0]:='S15';
StringGrid3.Cells[16,0]:='S16';
StringGrid3.Cells[0,1]:='A1';
StringGrid3.Cells[0,2]:='A2';
StringGrid3.Cells[0,3]:='A3';
StringGrid3.Cells[0,4]:='A4';
StringGrid3.Cells[0,5]:='A5';
StringGrid3.Cells[0,6]:='A6';
//Суммарный входной сигнал на входе А элемента
StringGrid4.ColWidths[0]:=44;
StringGrid4.Cells[0,0]:='';
StringGrid4.Cells[0,1]:='Буква1';
StringGrid4.Cells[0,2]:='Буква2';
StringGrid4.Cells[1,0]:='UA1';
StringGrid4.Cells[2,0]:='UA2';
StringGrid4.Cells[3,0]:='UA3';
StringGrid4.Cells[4,0]:='UA4';
StringGrid4.Cells[5,0]:='UA5';
StringGrid4.Cells[6,0]:='UA6';
{$I-}
Reset(f);
{$I+}
If IOResult=0 Then
begin
BitBtn5.Enabled:=True;
CloseFile(f);
end
else BitBtn5.Enabled:=False;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
i,j:byte;
sum,sum1,sum2,sum3,a:real;
s:string[3];
begin
for i:=0 to 5 do
for j:=0 to 15 do
begin
a:= random(9);
a:=a/10+0.1;
rand[j,i]:=a;
end;
load;
Summir;
end;
procedure TForm1.StringGrid2MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if StringGrid2.Cells[x_kurs,y_kurs]='1' then
StringGrid2.Cells[x_kurs,y_kurs]:='0'
else
StringGrid2.Cells[x_kurs,y_kurs]:='1';
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
Rewrite(f);
Seek(f,0);
Write(f,rand);
CloseFile(f);
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
begin
reset(f);
Seek(f,0);
read(f,rand);
CloseFile(f);
load;
Summir;
end;
Procedure TForm1.load;
Var
i,j:integer;
s:string[6];
begin
for i:=0 to 5 do
for j:=0 to 15 do
begin
str(rand[j,i]:0:1,s);
StringGrid3.Cells[j+1,i+1]:=s;
end;
end;
Procedure TForm1.Summir;
var
i,j:byte;
sum,sum1,sum2,sum3,a:real;
s:string[3];
begin
sum2:=0;
sum3:=0;
for i:=0 to 5 do
begin
sum:=0;
sum1:=0;
for j:=0 to 15 do
begin
if ferst[j]=1 then
sum:=sum+rand[j,i];
if second[j]=1 then
sum1:=sum1+rand[j,i];
end;
u_ferst[i]:=sum;
u_second[i]:=sum1;
str(sum:0:1,s);
StringGrid4.Cells[i+1,1]:=s;
str(sum1:0:1,s);
StringGrid4.Cells[i+1,2]:=s;
sum2:=sum2+ u_ferst[i];
sum3:=sum3+ u_second[i];
end;
sum2:=sum2/6;
sum3:=sum3/6;
str(sum2:2:3,s);
Label1.Visible:=true;
Label1.Caption:=s;
str(sum3:2:3,s);
Label2.Visible:=true;
Label2.Caption:=s;
por1:=(sum2+sum3)/2;
str(por1:2:3,s);
Label3.Visible:=true;
Label3.Caption:='Среднее по всей таблице: '+s;
BitBtn3.Enabled:=True;
BitBtn6.Enabled:=True;
BitBtn7.Enabled:=True;
end;
procedure TForm1.BitBtn6Click(Sender: TObject);
var
i,j:byte;
s:string[3];
sum,sum1:real;
begin
for i:=0 to 5 do
r[i]:=r_e[i];
for i:=0 to 8 do
for j:=0 to 16 do
StringGrid5.Cells[j,i]:='';
StringGrid5.Cells[0,0]:='';
StringGrid5.Cells[1,0]:='t0';
for i:=0 to 5 do
begin
str(r[i]:2:3,s);
StringGrid5.Cells[1,i+1]:=s;
end;
StringGrid5.Cells[0,1]:='W1';
StringGrid5.Cells[0,2]:='W2';
StringGrid5.Cells[0,3]:='W3';
StringGrid5.Cells[0,4]:='W4';
StringGrid5.Cells[0,5]:='W5';
StringGrid5.Cells[0,6]:='W6';
StringGrid5.Cells[0,7]:='U1';
StringGrid5.Cells[0,8]:='U2';
sum:=0;
sum1:=0;
for i:=0 to 5 do
begin
if u_ferst[i]>por1-0.1 then
sum:=sum+r[i];
if u_second[i]>por1-0.1 then
sum1:=sum1+r[i];
end;
por_al:=(sum+sum1)/2;
str(sum:2:3,s);
StringGrid5.Cells[1,7]:=s;
str(sum1:2:3,s);
StringGrid5.Cells[1,8]:=s;
str(por_al:2:3,s);
Label9.Visible:=true;
Label9.Caption:='Порог R-элемента: '+s;
if RadioButton1.Checked=true then
begin
j:=2;
while (sum>por_al)or(sum1<por_al) do
begin
if sum>por_al then
begin
sum:=0;
StringGrid5.Cells[j,0]:='1';
for i:=0 to 5 do
begin
if u_ferst[i]>por1-0.1 then
begin
if r[i]<>0 then
r[i]:=r[i]-0.1;
str(r[i]:2:3,s);
StringGrid5.Cells[j,i+1]:=s;
sum:=sum+r[i];
end;
end;
str(sum:2:3,s);
StringGrid5.Cells[j,7]:=s;
inc(j);
end;
if sum1<por_al then
begin
sum1:=0;
StringGrid5.Cells[j,0]:='2';
for i:=0 to 5 do
begin
if u_second[i]>por1-0.1 then
begin
if r[i]<>1 then
r[i]:=r[i]+0.1;
str(r[i]:2:3,s);
StringGrid5.Cells[j,i+1]:=s;
sum1:=sum1+r[i];
end;
end;
str(sum1:2:3,s);
StringGrid5.Cells[j,8]:=s;
inc(j);
end;
sum1:=0;
sum:=0;
for i:=0 to 5 do
begin
if u_ferst[i]>por1-0.1 then
sum:=sum+r[i];
if u_second[i]>por1-0.1 then
sum1:=sum1+r[i];
end;
end;
end
else
begin
j:=2;
while (sum<por_al)or(sum1>por_al) do
begin
if sum<por_al then
begin
sum:=0;
StringGrid5.Cells[j,0]:='1';
for i:=0 to 5 do
begin
if u_ferst[i]>por1-0.1 then
begin
if r[i]<>1 then
r[i]:=r[i]+0.1;
str(r[i]:2:3,s);
StringGrid5.Cells[j,i+1]:=s;
sum:=sum+r[i];
end;
end;
str(sum:2:3,s);
StringGrid5.Cells[j,7]:=s;
inc(j);
end;
if sum1>por_al then
begin
sum1:=0;
StringGrid5.Cells[j,0]:='2';
for i:=0 to 5 do
begin
if u_second[i]>por1-0.1 then
begin
if r[i]<>0 then
r[i]:=r[i]-0.1;
str(r[i]:2:3,s);
StringGrid5.Cells[j,i+1]:=s;
sum1:=sum1+r[i];
end;
end;
str(sum1:2:3,s);
StringGrid5.Cells[j,8]:=s;
inc(j);
end;
sum1:=0;
sum:=0;
for i:=0 to 5 do
begin
if u_ferst[i]>por1-0.1 then
sum:=sum+r[i];
if u_second[i]>por1-0.1 then
sum1:=sum1+r[i];
end;
end;
end;
BitBtn8.Enabled:=True;
end;
procedure TForm1.BitBtn7Click(Sender: TObject);
var
f,i,j:byte;
s:string[7];
sum,sum1,sum2:real;
begin
for i:=0 to 5 do
rg[i]:=r_e[i];
for i:=0 to 9 do
for j:=0 to 16 do
StringGrid6.Cells[j,i]:='';
StringGrid6.Cells[0,0]:='';
StringGrid6.Cells[1,0]:='t0';
for i:=0 to 5 do
begin
str(rg[i]:2:1,s);
StringGrid6.Cells[1,i+1]:=s;
end;
StringGrid6.Cells[0,1]:='W1';
StringGrid6.Cells[0,2]:='W2';
StringGrid6.Cells[0,3]:='W3';
StringGrid6.Cells[0,4]:='W4';
StringGrid6.Cells[0,5]:='W5';
StringGrid6.Cells[0,6]:='W6';
StringGrid6.Cells[0,7]:='U1';
StringGrid6.Cells[0,8]:='U2';
StringGrid6.Cells[0,9]:='S';
sum:=0;
sum1:=0;
for i:=0 to 5 do
begin
if u_ferst[i]>por1-0.1 then
sum:=sum+rg[i];
if u_second[i]>por1-0.1 then
sum1:=sum1+rg[i];
end;
por_al:=(sum+sum1)/2;
sum2:=sum+sum1;
str(sum:2:1,s);
StringGrid6.Cells[1,7]:=s;
str(sum1:2:1,s);
StringGrid6.Cells[1,8]:=s;
str(sum2:2:1,s);
StringGrid6.Cells[1,9]:=s;
str(por_al:2:1,s);
Label10.Visible:=true;
Label10.Caption:='Порог R-элемента: '+s;
if RadioButton1.Checked=true then
begin
j:=2;
while (sum>por_al)or(sum1<por_al) do
begin
if sum>por_al then
begin
sum:=0;
StringGrid6.Cells[j,0]:='1';
f:=0;
for i:=0 to 5 do
if u_ferst[i]>por1-0.1 then
begin
if rg[i]<>0 then
rg[i]:=rg[i]-0.1;
inc(f);
end;
for i:=0 to 5 do
begin
if rg[i]<>0 then
rg[i]:=rg[i]+f/10/6;
str(rg[i]:5:4,s);
StringGrid6.Cells[j,i+1]:=s;
sum2:=sum2+rg[i];
end;
for i:=0 to 5 do
if u_ferst[i]>por1-0.1 then
sum:=sum+rg[i];
str(sum:5:4,s);
StringGrid6.Cells[j,7]:=s;
str(sum2:5:4,s);
StringGrid6.Cells[j,9]:=s;
inc(j);
end;
if sum1<por_al then
begin
sum1:=0;
StringGrid6.Cells[j,0]:='2';
f:=0;
for i:=0 to 5 do
if u_second[i]>por1-0.1 then
begin
if rg[i]<>1 then
rg[i]:=rg[i]+0.1;
inc(f);
end;
for i:=0 to 5 do
begin
if rg[i]<>1 then
rg[i]:=rg[i]-f/10/6;
str(rg[i]:5:4,s);
StringGrid6.Cells[j,i+1]:=s;
sum2:=sum2+rg[i];
end;
for i:=0 to 5 do
if u_second[i]>por1-0.1 then
sum1:=sum1+rg[i];
str(sum1:5:4,s);
StringGrid6.Cells[j,8]:=s;
str(sum2:5:4,s);
StringGrid6.Cells[j,9]:=s;
inc(j);
end;
for i:=0 to 5 do
begin
if u_ferst[i]>por1-0.1 then
sum:=sum+rg[i];
if u_second[i]>por1-0.1 then
sum1:=sum1+rg[i];
end;
end;
end
else
begin
j:=2;
while (sum<por_al)or(sum1>por_al) do
begin
if sum<por_al then
begin
sum:=0;
StringGrid6.Cells[j,0]:='1';
f:=0;
for i:=0 to 5 do
if u_ferst[i]>por1-0.1 then
begin
if rg[i]<>1 then
rg[i]:=rg[i]+0.1;
inc(f);
end;
sum2:=0;
for i:=0 to 5 do
begin
if rg[i]<>1 then
rg[i]:=rg[i]-f/10/6;
str(rg[i]:5:4,s);
StringGrid6.Cells[j,i+1]:=s;
sum2:=sum2+rg[i];
end;
for i:=0 to 5 do
if u_ferst[i]>por1-0.1 then
sum:=sum+rg[i];
str(sum:5:4,s);
StringGrid6.Cells[j,7]:=s;
str(sum2:5:4,s);
StringGrid6.Cells[j,9]:=s;
inc(j);
end;
if sum1>por_al then
begin
sum1:=0;
StringGrid6.Cells[j,0]:='2';
f:=0;
for i:=0 to 5 do
if u_second[i]>por1-0.1 then
begin
if rg[i]<>0 then
rg[i]:=rg[i]-0.1;
inc(f);
end;
sum2:=0;
for i:=0 to 5 do
begin
if rg[i]<>0 then
rg[i]:=rg[i]+f/10/6;
str(rg[i]:5:4,s);
StringGrid6.Cells[j,i+1]:=s;
sum2:=sum2+rg[i];
end;
for i:=0 to 5 do
if u_second[i]>por1-0.1 then
sum1:=sum1+rg[i];
str(sum1:5:4,s);
StringGrid6.Cells[j,8]:=s;
str(sum2:5:4,s);
StringGrid6.Cells[j,9]:=s;
inc(j);
end;
end;
for i:=0 to 5 do
begin
if u_ferst[i]>por1-0.1 then
sum:=sum+rg[i];
if u_second[i]>por1-0.1 then
sum1:=sum1+rg[i];
end;
end;
BitBtn9.Enabled:=True;
end;
procedure TForm1.BitBtn8Click(Sender: TObject);
var
i,j,k,m:byte;
a:integer;
sum,sum1:real;
begin
k:=0;
for i:=0 to 3 do
for j:=0 to 3 do
begin
val(StringGrid7.Cells[j,i],m,a);
rasp[k]:=m;
inc(k);
end;
for i:=0 to 5 do
begin
sum:=0;
for j:=0 to 15 do
begin
if rasp[j]=1 then
sum:=sum+rand[j,i];
end;
u_rasp[i]:=sum;
end;
sum1:=0;
for i:=0 to 5 do
if u_rasp[i]>por1-0.1 then
sum1:=sum1+r[i];
if RadioButton1.Checked=true then
if sum1<por_al then
ShowMessage('Введена Буква1.')
else
ShowMessage('Введена Буква2.')
else
if sum1>por_al then
ShowMessage('Введена Буква1.')
else
ShowMessage('Введена Буква2.');
end;
procedure TForm1.StringGrid7MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if StringGrid7.Cells[x_kurs,y_kurs]='1' then
StringGrid7.Cells[x_kurs,y_kurs]:='0'
else
StringGrid7.Cells[x_kurs,y_kurs]:='1';
end;
procedure TForm1.StringGrid7SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
x_kurs:=ACol;
y_kurs:=ARow;
end;
procedure TForm1.BitBtn9Click(Sender: TObject);
var
i,j,k,m:byte;
a:integer;
sum,sum1:real;
begin
k:=0;
for i:=0 to 3 do
for j:=0 to 3 do
begin
val(StringGrid7.Cells[j,i],m,a);
rasp_g[k]:=m;
inc(k);
end;
for i:=0 to 5 do
begin
sum:=0;
for j:=0 to 15 do
begin
if rasp_g[j]=1 then
sum:=sum+rand[j,i];
end;
u_rasp_g[i]:=sum;
end;
sum1:=0;
for i:=0 to 5 do
if u_rasp_g[i]>por1-0.1 then
sum1:=sum1+rg[i];
if RadioButton1.Checked=true then
if sum1<por_al then
ShowMessage('Введена Буква1.')
else
ShowMessage('Введена Буква2.')
else
if sum1>por_al then
ShowMessage('Введена Буква1.')
else
ShowMessage('Введена Буква2.');
end;
end.
– Конец работы –
Используемые теги: Описание, работы, программы0.063
Если Вам нужно дополнительный материал на эту тему, или Вы не нашли то, что искали, рекомендуем воспользоваться поиском по нашей базе работ: Описание работы программы
Если этот материал оказался полезным для Вас, Вы можете сохранить его на свою страничку в социальных сетях:
Твитнуть |
Новости и инфо для студентов