Таблица 4.3 – СНДФ из букв Ф.И.О.
x1 x2 x3 x4 | F1 | F2 | F3 |
0 0 0 0 | 1 | 1 | 0 |
0 0 0 1 | 1 | 1 | 1 |
0 0 1 0 | 0 | 0 | 0 |
0 0 1 1 | 1 | 0 | 0 |
0 1 0 0 | 0 | 0 | 1 |
0 1 0 1 | 1 | 1 | 1 |
0 1 1 0 | 1 | 0 | 1 |
0 1 1 1 | 0 | 1 | 1 |
1 0 0 0 | 0 | 1 | 0 |
1 0 0 1 | 0 | 1 | 1 |
1 0 1 0 | 0 | 0 | 1 |
1 0 1 1 | 0 | 1 | 0 |
1 1 0 0 | 1 | 1 | 0 |
1 1 0 1 | 1 | 1 | 0 |
1 1 1 0 | 1 | 0 | 0 |
1 1 1 1 | 0 | 1 | 1 |
F1
F2
F3
Рисунок 4.2 – Диаграммы Венна для функций F1, F2, F3
3 Перевод даты рождения в двоичную систему
1982.0212
0.0212 | 0.3568 | 1.4272 | |||
2 | 2 | 2 | |||
0 | 0.0424 | 0 | 0.7136 | 0 | 0.8544 |
2 | 2 | 2 | |||
0 | 0.0848 | 1 | 1.4272 | 1 | 1.7088 |
2 | |||||
0 | 0.1696 | ||||
2 | |||||
0 | 0.3392 | ||||
2 | |||||
0 | 0.6784 | ||||
2 | |||||
1 | 1.3568 |
(1982.0212) 10=(11110111110.0000010101) 2
Пример 2: автор – Якухин Дмитрий
var
k:byte;
Form1: TForm1;
type R = set of 'A'..'Я';
implementation
{$R *.dfm}
procedure SNDF (y:byte; t:string);
var i:byte;
begin
for i:=1 to 5 do begin
Form1. StringGrid1. Cells [y, i]:=t[i];
end;
for i:=1 to 3 do begin
Form1. StringGrid2. Cells [i+4, y]:=t [i+1];
end;
end;
procedure Perebor (T:R; S:TMemo);
begin
if ('А' in T) then begin S. Lines. Add ('А= '+' 00001'); inc(k); SNDF (k, '00001'); Form1. StringGrid1. Cells [k, 0]:='А'; end;
if ('Б' in T) then begin S. Lines. Add ('Б= '+' 00010'); inc(k); SNDF (k, '00010'); Form1. StringGrid1. Cells [k, 0]:='Б'; end;
if ('В' in T) then begin S. Lines. Add ('В= '+' 00011'); inc(k); SNDF (k, '00011'); Form1. StringGrid1. Cells [k, 0]:='В'; end;
if ('Г' in T) then begin S. Lines. Add ('Г= '+' 00100'); inc(k); SNDF (k, '00100'); Form1. StringGrid1. Cells [k, 0]:='Г'; end;
if ('Д' in T) then begin S. Lines. Add ('Д= '+' 00101'); inc(k); SNDF (k, '00101'); Form1. StringGrid1. Cells [k, 0]:='Д'; end;
if ('Е' in T) then begin S. Lines. Add ('Е= '+' 00110'); inc(k); SNDF (k, '00110'); Form1. StringGrid1. Cells [k, 0]:='Е'; end;
if ('Ж' in T) then begin S. Lines. Add ('Ж= '+' 00111'); inc(k); SNDF (k, '00111'); Form1. StringGrid1. Cells [k, 0]:='Ж'; end;
if ('З' in T) then begin S. Lines. Add ('З= '+' 01000'); inc(k); SNDF (k, '01000'); Form1. StringGrid1. Cells [k, 0]:='З'; end;
if ('И' in T) then begin S. Lines. Add ('И= '+' 01001'); inc(k); SNDF (k, '01001'); Form1. StringGrid1. Cells [k, 0]:='И'; end;
if ('К' in T) then begin S. Lines. Add ('К= '+' 01010'); inc(k); SNDF (k, '01010'); Form1. StringGrid1. Cells [k, 0]:='К'; end;
if ('Л' in T) then begin S. Lines. Add ('Л= '+' 01011'); inc(k); SNDF (k, '01011'); Form1. StringGrid1. Cells [k, 0]:='Л'; end;
if ('М' in T) then begin S. Lines. Add ('М= '+' 01100'); inc(k); SNDF (k, '01100'); Form1. StringGrid1. Cells [k, 0]:='М'; end;
if ('Н' in T) then begin S. Lines. Add ('Н= '+' 01101'); inc(k); SNDF (k, '01101'); Form1. StringGrid1. Cells [k, 0]:='Н'; end;
if ('О' in T) then begin S. Lines. Add ('О= '+' 01110'); inc(k); SNDF (k, '01110'); Form1. StringGrid1. Cells [k, 0]:='О'; end;
if ('П' in T) then begin S. Lines. Add ('П= '+' 01111'); inc(k); SNDF (k, '01111'); Form1. StringGrid1. Cells [k, 0]:='П'; end;
if ('Р' in T) then begin S. Lines. Add ('Р= '+' 10000'); inc(k); SNDF (k, '10000'); Form1. StringGrid1. Cells [k, 0]:='Р'; end;
if ('С' in T) then begin S. Lines. Add ('С= '+' 10001'); inc(k); SNDF (k, '10001'); Form1. StringGrid1. Cells [k, 0]:='С'; end;
if ('Т' in T) then begin S. Lines. Add ('Т= '+' 10010'); inc(k); SNDF (k, '10010'); Form1. StringGrid1. Cells [k, 0]:='Т'; end;
if ('У' in T) then begin S. Lines. Add ('У= '+' 10011'); inc(k); SNDF (k, '10011'); Form1. StringGrid1. Cells [k, 0]:='У'; end;
if ('Ф' in T) then begin S. Lines. Add ('Ф= '+' 10100'); inc(k); SNDF (k, '10100'); Form1. StringGrid1. Cells [k, 0]:='Ф'; end;
if ('Х' in T) then begin S. Lines. Add ('Х= '+' 10101'); inc(k); SNDF (k, '10101'); Form1. StringGrid1. Cells [k, 0]:='Х'; end;
if ('Ц' in T) then begin S. Lines. Add ('Ц= '+' 10110'); inc(k); SNDF (k, '10110'); Form1. StringGrid1. Cells [k, 0]:='Ц'; end;
if ('Ч' in T) then begin S. Lines. Add ('Ч= '+' 10111'); inc(k); SNDF (k, '10111'); Form1. StringGrid1. Cells [k, 0]:='Ч'; end;
if ('Ш' in T) then begin S. Lines. Add ('Ш= '+' 11000'); inc(k); SNDF (k, '11000'); Form1. StringGrid1. Cells [k, 0]:='Ш'; end;
if ('Щ' in T) then begin S. Lines. Add ('Щ= '+' 11001'); inc(k); SNDF (k, '11001'); Form1. StringGrid1. Cells [k, 0]:='Щ'; end;
if ('Ъ' in T) then begin S. Lines. Add ('Ъ= '+' 11010'); inc(k); SNDF (k, '11010'); Form1. StringGrid1. Cells [k, 0]:='Ъ'; end;
if ('Ы' in T) then begin S. Lines. Add ('Ы= '+' 11011'); inc(k); SNDF (k, '11011'); Form1. StringGrid1. Cells [k, 0]:='Ы'; end;
if ('Ь' in T) then begin S. Lines. Add ('Ь= '+' 11100'); inc(k); SNDF (k, '11100'); Form1. StringGrid1. Cells [k, 0]:='Ь'; end;
if ('Э' in T) then begin S. Lines. Add ('Э= '+' 11101'); inc(k); SNDF (k, '11101'); Form1. StringGrid1. Cells [k, 0]:='Э'; end;
if ('Ю' in T) then begin S. Lines. Add ('Ю= '+' 11110'); inc(k); SNDF (k, '11110'); Form1. StringGrid1. Cells [k, 0]:='Ю'; end;
if ('Я' in T) then begin S. Lines. Add ('Я= '+' 11111'); inc(k); SNDF (k, '11111'); Form1. StringGrid1. Cells [k, 0]:='Я'; end;
end;
procedure TForm1. BitBtn1Click (Sender: TObject);
var F, I, O:R;
h, j, S:byte;
begin
Memo1. Clear;
Memo2. Clear;
Memo3. Clear;
k:=0;
S:=0;
F:=['Я', 'К', 'У', 'Х', 'И', 'Н'];
I:=['Д', 'М', 'И', 'Т', 'Р'];
O:=['Е', 'Р', 'Г', 'В', 'И'];
perebor (F, Memo1);
perebor (I, Memo2);
perebor (O, Memo3);
for j:=1 to 5 do begin
for h:=1 to 19 do begin
if StringGrid1. Cells [h, j]='1' then inc(s);
end;
StringGrid1. Cells [17, j]:=IntToStr(S);
S:=0;
(yegorov-p Rulezzz;)}
end;
end;
procedure TForm1. FormCreate (Sender: TObject);
var
g:byte;
begin
StringGrid1. Cells [0,2]:='F1';
StringGrid1. Cells [0,3]:='F2';
StringGrid1. Cells [0,4]:='F3';
StringGrid2. Cells [1,0]:='X1';
StringGrid2. Cells [2,0]:='X2';
StringGrid2. Cells [3,0]:='X3';
StringGrid2. Cells [4,0]:='X4';
StringGrid2. Cells [5,0]:='F1';
StringGrid2. Cells [6,0]:='F2';
StringGrid2. Cells [7,0]:='F3';
for g:=0 to 15 do
StringGrid2. Cells [0, g+1]:=IntToStr(g);
for g:=0 to 7 do
StringGrid2. Cells [1, g+1]:='0';
for g:=8 to 15 do
StringGrid2. Cells [1, g+1]:='1';
for g:=0 to 3 do
StringGrid2. Cells [2, g+1]:='0';
for g:=4 to 7 do
StringGrid2. Cells [2, g+1]:='1';
for g:=8 to 11 do
StringGrid2. Cells [2, g+1]:='0';
for g:=12 to 15 do
StringGrid2. Cells [2, g+1]:='1';
for g:=1 to 2 do begin
StringGrid2. Cells [3, g]:='0';
StringGrid2. Cells [3, g+2]:='1';
StringGrid2. Cells [3, g+4]:='0';
StringGrid2. Cells [3, g+6]:='1';
StringGrid2. Cells [3, g+8]:='0';
StringGrid2. Cells [3, g+10]:='1';
StringGrid2. Cells [3, g+12]:='0';
StringGrid2. Cells [3, g+14]:='1';
end;
for g:=1 to 16 do begin
if g div 2 = g/2 then
StringGrid2. Cells [4, g]:='1'
else
StringGrid2. Cells [4, g]:='0';
end;
end;
Function Dec2Bin (j:integer):string;
begin
result:='';
while j>=1 do
begin
result:=IntToStr (j mod 2)+result;
j:=j div 2;
end;
end;
Function Dec2BinDrob (j:real):string;
var
i:byte;
begin
result:='';
for i:=1 to 11 do
begin
result:=FloatToStr (int(j*2))+result;
j:=j*2;
if int (j*2)>1 then j:=j‑1;
end;
end;
procedure TForm1. BitBtn3Click (Sender: TObject);
var p, p2, S, S2, S3:string;
i:byte;
begin
p:=Edit1. Text;
p2:='0,'+Edit3. Text;
S:=Dec2Bin (StrToInt(p));
S2:=Dec2BinDrob (StrToFloat(p2));
for i:=11 downto 1 do begin
S3:=S3+S2 [i];
end;
Edit2. Text:=S+'.'+S3;
end;
procedure TForm1. BitBtn4Click (Sender: TObject);
var i:byte;
P:string;
begin
for i:=1 to 16 do begin
if StringGrid2. Cells [5, i]='1' then begin
P:=StringGrid2. Cells [1, i]+StringGrid2. Cells [2, i]+
StringGrid2. Cells [3, i]+StringGrid2. Cells [4, i];
Label7. Caption:=Label7. Caption+' '+P;
end;
end;
for i:=1 to 16 do begin
if StringGrid2. Cells [6, i]='1' then begin
P:=StringGrid2. Cells [1, i]+StringGrid2. Cells [2, i]+
StringGrid2. Cells [3, i]+StringGrid2. Cells [4, i];
Label8. Caption:=Label8. Caption+' ' +P;
end;
end;
for i:=1 to 16 do begin
if StringGrid2. Cells [7, i]='1' then begin
P:=StringGrid2. Cells [1, i]+StringGrid2. Cells [2, i]+
StringGrid2. Cells [3, i]+StringGrid2. Cells [4, i];
Label9. Caption:=Label9. Caption+' '+P;