Головна |
Для запуску програми необхідно запустити файл 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 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 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 begin if sum 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 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 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 begin if sum 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 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 ShowMessage ('Введена Буква1.') else ShowMessage ('Введена Буква2.') else if sum1> por_al then ShowMessage ('Введена Буква1.') else ShowMessage ('Введена Буква2.'); end; end.