. , , ,

,,,

,

, . - . , - , , , , . , , , PC.

 

 

1. ........................................................................................... 6

2. .......................................................................... 7

3. ............................................. 8

4. ....................................... 9

4.1. R(x) ...... 11

4.2.

.......................................................................................... 14

5. ........................................................... 15

6. ......................................................... 16

7. ....................................................... 21

----------------------------------------------------------------------------------------------------

........................................................................................ 23

1 ............................................................................... 24

2 ............................................................................... 30


1

, , ( , -).

, .

, , , .

  , ( ).

. . -

.

.

2

31 ( n=31 ,s=1)

.

. , , .


3

1. x:

G(x)=x4+x2+1 Û 0010101;

G(x)×x=x5+x3+x Û 0101010.

2. 2 .

:

G1(x)+G2(x)=>G3(x);

G1(x) -G2(x)=>G3(x);

G2(x)+G1(x)=>G3(x);

:

G1(x)= x5 +x3+x;

G2(x)=x4 +x3 +1;

G3(x)=G1(x) Å G2(x) = x5 +x4+x+1.

3. , 2 :

G1(x)=x6+x4+x3 ;

G2(x)=x3+x2+1 .

 


x6+x4+x3 x3+x2+1

Å x6+x5+x3 x3 +x2

x5 + x4

Å x5 + x4 +x2

x2

:

1011000 1101

Å1101 1100

1100

Å 1101

100

.


4

. -, ,.. . xn+1. .

, k- Q(x) xr , P(x) , r. Q(x) xr , Q(x), - r. xrQ(x) C(x) , Q(x).

Q(x) xr R(x)

¾¾¾¾ = C(x) + ¾¾¾ , (1)

P(x) P(x)

R(x) - Q(x) xr P(x).

C(x) , Q(x) , C(x)

k- . , , .. (r-1). , R(x) r.

(1) P(x) :

F(x) = C(x) P(x) = Q(x) xr + R(x) (2)

, n-

:

1) Q(x) xr

R(x) , Q(x) xr P(x);

2) C(x) k- P(x).

-

k , (n-k)

.

-

, .


4.1 R(x)

31

( n=31, s=1)

.

1. - m :

m = log2 (n+1) = log2 (31+1) = 5.

2. k :

k = n-m = 26,

. (31, 26 ) - .

3. , 󠠠 k-:

G(x)=00000000000000000000000101= x2 +1.

4. m=n-k=5 . G(x) xm :

xm G(x)= (x2+1) x5= x7+ x5 =0000000000000000000000010100000.

5. -P(x) . (d0=3) P(x) m=n-k=5 d0 =3.

P(x) :

P(x)= x5 + x4 +x3 +x 2 +1 = 111101.

6. R(x) G(x)×x m -

P(x)

x7+ x5 x5 + x4 +x3 +x 2 +1 10100000 111101

x7 + x6 +x5 +x 4 +x2 x2 +x +1 111101 111

x6 + x4 +x2 101010

x6 + x5 +x4 +x 3 +x 111101

x5 + x3 +x2 +x 101110

x5 + x4 +x3 +x 2 +1 111101

x4 +x +1 10011

R(x)= x4+x+1 =10011.

7. F(x) :

F(x)=xm G(x)ÅR(x)= x7+ x5+ x4+x+1 =0000000000000000000000010110011.

8. , :

F¢(x)=F(x) Å E(x)= 1000000000000000000000010110011.

9. F1(x) - , ( ) W £S

1000000000000000000000010110011 111101

111101

111010

111101

111000

111101

101000

111101

101010

111101

101110

111101

100110

111101

110110

111101

101100

111101

100010

111101

111110

111101

110010

111101

111111

111101

100011

111101

11110

w

w>s .

10.

.9 w £ s.

a) 0000000000000000000000101100111 111101

111101

100011

111101

111101

111101

1 Þ w=s .

2 :

0000000000000000000000101100111

Å 1

0000000000000000000000101100110

1

0000000000000000000000010110011

, .


4.2

31

( n=31, s=1) 31 .

.

1. , 󠠠 k-:

G(x)=00000000000000000000000101= x2 +2.

2.

00000000000000000000000101

111101

00000000000000000000000101

00000000000000000000000101

00000000000000000000000101

00000000000000000000000101

00000000000000000000000101

0000000000000000000000011001001

3.

4.1.


5.

Ciclic code



򠠠


6.

. ,

.

Program Cyclic_Code;

Uses

Crt,_CC31,_Serv;

Var

m,mm:Move_code;

p:Polinom;

r:Rest;

i,Mainflag,From,Error:integer;

Switch:byte;

Key:boolean;

begin

Repeat

Key:=true;

TextColor(11);

TextBackGround(7);

Clrscr;

SetWindow(24,10,45,14,2,' ');

Switch:=GetMainMenuChoice;

case Switch of

1:begin

About;

Readln;

Key:=False;

end;

2: begin

TextColor(0);

ClrScr;

SetWindow(25,10,40,13,1,' ');

Switch:=GetSubMenuChoice;

case Switch of

1:begin

TextBackGround(0);

TextColor(15);

ClrScr;

SetWindow(1,1,79,24,2,' ');

TextColor(14);

GotoXY(2,2);

Init(m,p,r,MainFlag);

Write( 젠 ');

TextColor(2);

for i:=n downto 0 do

begin

if(i<n-n1+1)then Textcolor(9);

Write(m[i]);

end;

TextColor(14);

GotoXY(2,3);

Write(' 젠 ');

TextColor(13);

for i:=n1 downto 0 do

Write(p[i]);

TextColor(14);

GotoXY(2,4);

Write(' 2 (F(x)+P(x)): ');

FxPx(m);

TextColor(9);

for i:=n downto 0 do

begin

if(i<n1)then TextColor(2);

Write(m[i]);

end;

TextColor(14);

GotoXY(2,5);

Write(': ');

Divizion(m,r,p,Mainflag);

TextColor(11);

for i:=n1 downto Mainflag do

Write(r[i]);

GotoXY(2,6);

TextColor(14);

Write(' : ');

BildMoveCode(m,r,Mainflag);

TextColor(9);

for i:=n downto 0 do

begin

if(i<n1) then TextColor(11);

Write(m[i]);

end;

GotoXY(2,7);

TextColor(14);

Write(' ... ');

MakeError(m,Error);

TextColor(9);

for i:=n downto 0 do

begin

if(i=Error)then

TextColor(12)

else

TextColor(9);

write(m[i]);

end;

GotoXY(2,8);

TextColor(14);

Write(' ! ');

TextColor(9);

Correction(m,p,r);

for i:=n downto 0 do

begin

if(i=Error)then

TextColor(10)

else

TextColor(9);

write(m[i]);

end;

TextColor(14);

GotoXY(2,9);

Write(' : ');

Decoder(m);

TextColor(2);

for i:=n downto 0 do

begin

if(i<n-n1+1)then Textcolor(9);

Write(m[i]);

end;

Key:=false;

end;

2:begin

TextBackGround(0);

TextColor(15);

ClrScr;

SetWindow(1,1,79,24,2,'');

TextColor(14);

GotoXY(2,2);

Init(m,p,r,MainFlag);

Write(' : ');

TextColor(2);

for i:=n downto 0 do

begin

if(i<n-n1+1)then Textcolor(9);

Write(m[i]);

end;

TextColor(14);

GotoXY(2,3);

Write(' : ');

TextColor(13);

for i:=n1 downto 0 do

Write(p[i]);

TextColor(14);

GotoXY(2,4);

Write(' : ');

BildMoveCodeMultiplication(m);

TextColor(9);

for i:=n downto 0 do

Write(m[i]);

GotoXY(2,5);

TextColor(14);

Write('  ... ');

MakeError(m,Error);

TextColor(9);

for i:=n downto 0 do

begin

if(i=Error)then

TextColor(12)

else

TextColor(9);

write(m[i]);

end;

GotoXY(2,6);

TextColor(14);

Write('  ! ');

TextColor(9);

Correction(m,p,r);

for i:=n downto 0 do

begin

if(i=Error)then

TextColor(10)

else

TextColor(9);

write(m[i]);

end;

Key:=false;

end;

end;

TextColor(14);

GotoXY(2,22);

Write(' ...');

Readln;

end;

3:begin

ClrScr;

GotoXY(1,24);

TextColor(14);

Writeln('  ...');

Readln;

TextBackGround(0);

TextColor(15);

ClrScr;

Key:=true;

end;

end;

Until Key;

end.


7 .

: 0000011010111110011110110110110

: 111101

Ce 2 (F(x)+P(x)): 1101011111001111011011011000000

: 010101

: 1101011111001111011011011010101

... 1101011111001110011011011010101

! 1101011111001111011011011010101

: 0000011010111110011110110110110

...

: 0000001010110000011111010001011

: 111101

: 0110000011111010000100100101111

... 0110000011111010000100100101101

! 0110000011111010000100100101111

...

:

.

.

, - , , .

, , "

" , , .


1. ( ). ..,

.., .. . , -

,1978. 252 .

2. Turbo Pascal . ..,

.. , .,,1997.495 .


1

_31.

Unit _CC31;

Interface

Uses

Crt;

Const

n=30; { +䠠 }

n1=5; { }

Type

Move_code=array[0..n] of byte; { F(x) }

Rest=array[0..n1] of byte; { ꠠ }

Polinom=array[0..n1] of byte; { P(x) }

Procedure Init(var m1:Move_code;var p1:Polinom;

var r1:Rest;var flag:integer);

Procedure FxPx(var m6:Move_Code);

Procedure Divizion(var m2:Move_code;var r2:Rest;

p2:Polinom;var flag:integer);

Procedure BildMoveCode(var m3:Move_code;r3:Rest;var flag:integer);

Procedure Decoder(var m6:Move_Code);

Procedure MakeError(var m4:Move_code;var err:integer);

Procedure BildMoveCodeMultiplication(var m7:Move_Code);

Procedure Correction(var m5:Move_code;p5:Polinom;var r5:Rest);

Implementation

Procedure Init;

var

i:integer;

begin

p1[5]:=1;

p1[4]:=1;

p1[3]:=1;

p1[2]:=1;

p1[1]:=0;

p1[0]:=1;

flag:=0;

for i:=n1 downto 0 do

r1[i]:=0;

Randomize;

for i:=n-n1 downto 0 do

m1[i]:=random(2);

end;

Procedure FxPx(var m6:Move_Code);

var

i:integer;

k:byte;

begin

k:=5;

while(k>0) do

begin

for i:=n downto 1 do

m6[i]:=m6[i-1];

dec(k);

end;

for i:=n1-1 downto 0 do

m6[i]:=0;

end;

Procedure Divizion(var m2:Move_code;var r2:Rest;

p2:Polinom;var flag:integer);

label

RETURN;

var

i,j,i1,kol,Countzero:integer;

begin

j:=n;

RETURN:while((j>=0)and(m2[j]=0))do dec(j);

if(j>n1)

then begin

for i:=n1 downto 0 do

begin

r2[i]:=m2[j];

dec(j);

end;

while(j>=0)do

begin

for i:=n1 downto 0 do

r2[i]:=r2[i] xor p2[i];

i1:=n1;

while((i1>=0)and(r2[i1]=0))do dec(i1);

if(i1=-1)then goto RETURN;

Kol:=n1-i1;

while(Kol>0)do

begin

for i:=n1 downto 1 do

r2[i]:=r2[i-1];

dec(Kol);

end;

Kol:=n1-i1;

while((Kol>0)and(j>=0))do

begin

r2[Kol-1]:=m2[j];

dec(Kol);

dec(j);

end;

if((j=-1)and(Kol=0))

then begin

for i:=n1 downto 0 do

r2[i]:=r2[i] xor p2[i];

end

else flag:=Kol;

end;

end

else if(n1=j)

then begin

for i:=n1 downto 0 do

begin

r2[i]:=m2[j];

dec(j);

end;

for i:=n1 downto 0 do

r2[i]:=r2[i] xor p2[i]

end

else if(j<n1)

then begin

for i:=j downto 0 do

r2[i]:=m2[i]

end;

end;

Procedure BildMoveCode(var m3:Move_code;r3:Rest;var flag:integer);

var

i,k:integer;

begin

if(flag>0)then

begin

k:=n1-flag;

for i:=n1 downto flag do

begin

m3[k]:=r3[i];

dec(k);

end;

end

else begin

for i:=n1-1 downto 0 do

m3[i]:=r3[i];

end;

end;

Procedure MakeError(var m4:Move_code;var err:integer);

begin

Randomize;

err:=Random(n);

m4[err]:=m4[err] xor 1;

end;

Procedure Decoder(var m6:Move_Code);

var

i:integer;

k:byte;

begin

k:=5;

while(k>0) do

begin

for i:=0 to n-1 do

m6[i]:=m6[i+1];

dec(k);

end;

for i:=n downto n-n1+1 do

m6[i]:=0;

end;

Procedure BildMoveCodeMultiplication(var m7:Move_Code);

var

m1,m2,m3,m4,mm:Move_Code;

i,j:integer;

begin

mm:=m7;

m1:=m7;

for j:=0 to 1 do

begin

for i:=n downto 1 do

m1[i]:=m1[i-1];

m1[j]:=0;

end;

m2:=m7;

for j:=0 to 2 do

begin

for i:=n downto 1 do

m2[i]:=m2[i-1];

m2[j]:=0;

end;

m3:=m7;

for j:=0 to 3 do

begin

for i:=n downto 1 do

m3[i]:=m3[i-1];

m3[j]:=0;

end;

m4:=m7;

for j:=0 to 4 do

begin

for i:=n downto 1 do

m4[i]:=m4[i-1];

m4[j]:=0;

end;

for i:=n downto 0 do

m7[i]:=mm[i] xor m1[i]xor m2[i]xor m3[i] xor m4[i];

end;

Procedure Correction(var m5:Move_code;p5:Polinom;var r5:Rest);

var

i,Correctflag,i1:integer;

Count,Countcarry,Carryflag:byte;

begin

Correctflag:=0;

Countcarry:=0;

repeat

for i:=n1 downto 0 do

r5[i]:=0;

Count:=0;

Divizion(m5,r5,p5,Correctflag);

i1:=n1;

while((i1>=Correctflag)and(r5[i1]=0))do dec(i1);

if({(i1=Correctflag-1) or

(}(i1=Correctflag)and(r5[Correctflag]=1)){)}

then m5[0]:=m5[0] xor r5[Correctflag]

else begin

Carryflag:=m5[n];

for i:=n downto 1 do

m5[i]:=m5[i-1];

m5[0]:=Carryflag;

inc(Countcarry);

end;

until ({(i1=Correctflag-1) or

(}(i1=Correctflag)and(r5[Correctflag]=1));{);}

while (Countcarry>0) do

begin

Carryflag:=m5[0];

for i:=0 to n-1 do

m5[i]:=m5[i+1];

m5[n]:=Carryflag;

dec(Countcarry);

end;

end;

end.

2

_Serv.

 

Unit _SERV;

Interface

Uses

Crt,Dos;

Const

EmptyBorder =0;

SingleBorder =1;

DoubleBorder =2;

BorderChar:array[0..2,1..6] of Char=

((#32,#32,#32,#32,#32,#32),

(#218,#196,#191,#179,#192,#217),

(#201,#205,#187,#186,#200,#188));

MaxChar =80;

MaxLine =25;

MenuTop =3;

SubMenuTop =2;

MenuLine :array[1..MenuTop]of string[20]=

(' ...',' ' ');

SubMenuLine :array[1..SubMenuTop]of string[20]=

(' ' , ' ');

Procedure SetWindow(x1,y1,x2,y2,Bord:byte;Header:string);

Procedure CursorOff;

Function GetMainMenuChoice:byte;

Function GetSubMenuChoice:byte;

Procedure About;

Implementation

Procedure SetWindow(x1,y1,x2,y2,Bord:byte;Header:string);

var

i:integer;

begin

if not ((x1<1) or (x2<=x1) or

(y1<1) or (y2<=y1) or (x2>MaxChar) or

(y2>MaxLine) or (Bord>2)) then

begin

GotoXY(x1,y1);

Write(BorderChar[Bord,1]);

for i:=1 to x2-x1-1 do

begin

GotoXY(x1+i,y1);

Write(BorderChar[Bord,2]);

end;

GotoXY(x2,y1);

Write(BorderChar[Bord,3]);

for i:=1 to y2-y1-1 do

begin

GotoXY(x1,y1+i);

Write(BorderChar[Bord,4]);

GotoXY(x2,y1+i);

Write(BorderChar[Bord,4]);

end;

GotoXY(x1,y2);

Write(BorderChar[Bord,5]);

for i:=1 to x2-x1-1 do

begin

GotoXY(x1+i,y2);

Write(BorderChar[Bord,2]);

end;

GotoXY(x2,y2);

Write(BorderChar[Bord,6]);

end;

GotoXY((x2-x1-ord(Header[0])) div 2+x1,y1);

Write(Header)

end;

Procedure CursorOff;

begin

asm

mov ah,1

mov ch,20h

int 10h

end;

end;

Function GetMainMenuChoice:byte;

var

Count:byte;

i:integer;

ch,ch1:char;

begin

Count:=1;

while KeyPressed do

ch:=Readkey;

repeat

for i:=1 to MenuTop do

begin

if(i=Count)then

begin

HighVideo;

TextColor(0);

end

else

begin

LowVideo;

TextColor(8);

end;

GotoXY(25,10+i);

Writeln(MenuLine[i]);

CursorOff;

end;

if KeyPressed

then begin

ch:=Readkey;

if(ch=#0)

then begin

ch1:=Readkey;

case ch1 of

#72 : if(Count>1)

then dec(Count);

#80 : if(Count<MenuTop)

then inc(Count);

end;

end;

end;

until(ch=#13);

GetMainMenuChoice:=Count;

end;

Function GetSubMenuChoice:byte;

var

Count:byte;

i:integer;

ch,ch1:char;

begin

Count:=1;

while KeyPressed do

ch:=Readkey;

repeat

for i:=1 to SubMenuTop do

begin

if(i=Count)then

begin

HighVideo;

TextColor(9);

end

else

begin

LowVideo;

TextColor(1);

end;

GotoXY(26,10+i);

Writeln(SubMenuLine[i]);

CursorOff;

end;

if KeyPressed

then begin

ch:=Readkey;

if(ch=#0)

then begin

ch1:=Readkey;

case ch1 of

#72 : if(Count>1)

then dec(Count);

#80 : if(Count<SubMenuTop)

then inc(Count);

end;

end;

end;

until(ch=#13);

GetSubMenuChoice:=Count;

end;

Procedure About;

begin

TextColor(15);

SetWindow(5,1,75,3,1,' ');

TextColor(10);

GotoXY(6,2);

TextColor(10+128);

Write(' -57. .

䔠 ');

end;

end.

, . - .

 

 

 

! , , , .
. , :