Передача информации по каналу с решающей обратной связью

end;

from:=4;

key:=readkey;

if key=#0 then key:=readkey;

case key of

#27:begin {Esc}

from:=n_pun;

n_pun:=4;

break;

end;

#59:helper; {F1}

#80:begin {Вниз}

n_pun:=n_pun+1;

if n_pun>4 then n_pun:=1;

end;

#72:begin {Вверх}

n_pun:=n_pun-1;

if n_pun<1 then n_pun:=4;

end;

end;

until (key=#13) or (key=#77);

case n

_pun of

{1:visio;}

2:helper; {помощь}

3:o_progr; {о программе}

4:final(from); {выход}

end;

until false;

end;

(* процедура ввода кода *)

Procedure Input;

Begin

X:=2;

GotoXY(Begin_Line+x,CodeLine-1);

Write('k9k8k7k6k5k4k3k2k1m5m4m3m2m1');

For i:=1 to k Do

Begin

GotoXY(Begin_Line+X+2*(i-1),CodeLine);

If Code[i]Then Write('1')Else Write('0');

End;

TextBackGround(MenuColor);

GotoXY(Begin_Line+X,CodeLine);

If Code[x div 2]Then Write('1') Else Write('0');

Repeat

Key:=ReadKey;

Case Key of

#0:Begin

Key:=ReadKey;

TextBackGround(GroundColor);

GotoXY(Begin_Line+X,CodeLine);

If Code[x div 2]Then Write('1') Else Write('0');

Case Key of

#77:If X<2+(k-1)*2 Then X:=X+2 else x:=2;

#75:If X>2 Then X:=X-2 else x:=2+(k-1)*2;

End;

TextBackGround(MenuColor);

GotoXY(Begin_Line+X,CodeLine);

If Code[x div 2]Then Write('1') Else Write('0');

End;

#27:quit;

{begin clrscr; cursor(off);init; final(from); end;}

#32:Begin

Code[x div 2]:=Not Code[x div 2];

GotoXY(Begin_Line+X,CodeLine);

If Code[x div 2]Then Write('1') Else Write('0');

End;

End;

Until Key=#13;

TextBackGround(GroundColor);

GotoXY(Begin_Line+X,CodeLine);

If Code[x div 2]Then Write('1') Else Write('0');

End;

(* процедура кодирования сообщения *)

Procedure Coder;

Begin

For i:=1 to n do G_Code[i]:=0;

For i:=1 to k do Begin

If Code[k+1-i] Then Begin

For j:=1 to n Do Begin

G_Code[j]:=G_Code[j]+a[i,j];

If g_Code[j]=2 Then G_Code[j]:=G_Code[j]-2;

End;

End;

End;

For i:=1 to n Do Begin

GotoXY(Begin_Line+2*i,G_CodeLine);

Write(G_Code[i]);

End;

End;

(* процедура сдвига кода влево *)

procedure Left;

begin

x:=G_Code[1];

for i:=1 to n-1 do G_Code[i]:=G_Code[i+1];

G_Code[14]:=x; {!!!!!!!!!!15!!!!!!111}

end;

(* процедура сдвига кода вправо *)

Procedure Shift_Rigth;

Begin

x:=G_Code[14];{!!!!!!!!!!!15!!!!!!!!1}

For i:=n downto 2 do G_Code[i]:=G_Code[i-1];

G_Code[1]:=x;

End;

(* процедура декодирования *)

Procedure decoder;

Var b:Array[1 n] of byte;

w,AmountShift:byte;

Begin

AmountShift:=0;

Repeat

w:=0;

For i:=1 to n Do b[i]:=G_Code[i];

For i:=1 to n-stepen+1 Do

Begin

If b[i]=1 Then

Begin

For j:=i to stepen+i do

Begin

b[j]:=b[j]+Polynom[j-i+1];

if b[j]=2 Then

b[j]:=0;

End;

End;

End;

For i:=1 to n do If b[i]=1 Then Inc(w);

If w>s Then

Begin

Left;

Inc(AmountShift);

End

Else

Begin

For i:=1 to n Do

Begin

G_Code[i]:=G_Code[i]+b[i];

If G_Code[i]=2 then G_Code[i]:=0;

End;

w:=0;

End;

Until (w=0) Or (AmountShift=n);

If w=0 Then

Begin

While AmountShift>0 Do

Begin

Dec(AmountShift);

Shift_Rigth;

End;

For i:=1 to n Do

Begin

GotoXY(Begin_Line+2*i,D_CodeLine);

write(G_Code[i]);

End;

End

Else

Begin

GotoXY(Begin_Line+2,D_CodeLine);

Write('Невозможно расшифровать комбинацию');

End;

End;

(* процедура изменения кода *)

Procedure Change_Code;

begin

x:=2;

For i:=1 to n Do Begin

GotoXY(Begin_Line+X+2*(i-1),C_CodeLine);

If G_Code[i]=1Then Write('1')Else Write('0');

End;

TextBackGround(MenuColor);

GotoXY(Begin_Line+X,C_CodeLine);

If G_Code[x div 2]=1Then Write('1') Else Write('0');

Repeat

Key:=ReadKey;

Case Key of

#0:Begin

Key:=ReadKey;

TextBackGround(GroundColor);

GotoXY(Begin_Line+X,C_CodeLine);

If G_Code[x div 2]=1Then Write('1') Else Write('0');

Case Key of

#77:If X<2+(n-1)*2 Then X:=X+2 else x:=2;

#75:If X>2 Then X:=X-2 else x:=2+(n-1)*2;

End;

TextBackGround(MenuColor);

GotoXY(Begin_Line+X,C_CodeLine);

If G_Code[x div 2]=1Then Write('1') Else Write('0');

End;

#27:Exit;

#32:Begin

G_Code[x div 2]:=1-G_Code[x div 2];

GotoXY(Begin_Line+X,C_CodeLine);

If G_Code[x div 2]=1 Then Write('1') Else Write('0');

End;

End;

Until Key=#13;

TextBackGround(GroundColor);

GotoXY(Begin_Line+X,C_CodeLine);

If G_Code[x div 2]=1Then Write('1') Else Write('0');

end;

(*Процедура ввода и обработки кодового сообщения*)

procedure visio;

Begin

Cursor(Off);

Init;

Repeat

ClrScr;

wind(2,3,78,24,white,black,' Кодирование ');

GotoXY(3,12);

TextColor(0);

GotoXY(3,codeLine);

Write('Посылаемый код :');

GotoXY(3,G_codeLine);

Write('Закодированный код :');

GotoXY(3,C_codeLine);

Write('Измененный код :');

GotoXY(3,D_codeLine);

Write('Декодированный код :');

Input;

Coder;

Change_Code;

decoder;

Repeat

Key:=ReadKey;

If Key=#27 Then exit;

Until Key=#13;

Until False;

End;

(* ГЛАВНЫЙ МОДУЛЬ *)

(* Вывод меню.Вызов соответствующих модулей *)

begin

cursor(off);

init;

n_pun:=1;

win(1,1,80,25,3);

repeat

repeat

vnizu;

textcolor(0);

write('Выход');

wind(4,3,20,6,white,0,'');

for i:=1 to 4 do

begin

if i=n_pun then

begin

textbackground(3);

textcolor(white);

end

else begin

textbackground(white);

textcolor(0);

end;

if i=4 then write(menu_p[4])

else writeln(menu_p[i]);

end;

from:=4;

key:=readkey;

if key=#0 then key:=readkey;

case key of

#27:begin {Esc}

from:=n_pun;

n_pun:=4;

break;

end;

#59:helper; {F1}

#80:begin {Вниз}

n_pun:=n_pun+1;

if n_pun>4 then n_pun:=1;

end;

#72:begin {Вверх}

n_pun:=n_pun-1;

if n_pun<1 then n_pun:=4;

end;

end;

until (key=#13) or (key=#77);

case n_pun of

1:visio;

2:helper; {помощь}

3:o_progr; {о программе}

4:final(from); {выход}

end;

until false;

end.

Страница:  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15 
 16  17 


Другие рефераты на тему «Коммуникации, связь и радиоэлектроника»:

Поиск рефератов

Последние рефераты раздела

Copyright © 2010-2024 - www.refsru.com - рефераты, курсовые и дипломные работы