📄 scramble.cpp
字号:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int *scramble(int *string_scramble)
{
int *p_scramble = (int *)malloc(768*sizeof(int));
static int string_afterscramble[768];
// int mask[42]={1,1,0,0,0,1,1,0,0,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1};
int mask[42]={1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,0,0,0,1,1};
int lcode_generator[42]={1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int longcode[768*32];
int a=0,b=0;
int i=0;
int j=0;
for(i=0;i<=768*32-1;i++)
{
a=0;
for(j=0;j<=41;j++) //生成长码
{
a=a ^ (mask[j]&lcode_generator[j]);
}
longcode[i]=a;
b=lcode_generator[41]; //寄存器移位
for(j=41;j>=1;j--)
{
lcode_generator[j]=lcode_generator[j-1];
}
lcode_generator[0]=b;
for(j=0;j<=41;j++)
{
if(j==1||j==2||j==3||j==5||j==6||j==7||j==10||j==16||j==17||j==18||j==19||j==21||j==22||j==25||j==26||j==27||j==31||j==33||j==35) //多项式所包含项
{
lcode_generator[j]=lcode_generator[j]^b;
}
//多项式不包含项
}
}
j=0;
for(i=0;i<=768*32-1;i++)
{
if(i%32==0) //分频
{
string_afterscramble[j] =*(string_scramble+j)^longcode[i]; //与交织处理后的码元模2相加输出
j++;
}
}
return (string_afterscramble);
}
void main()
{
int string[768]={1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,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,1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,
1,0,1,1,0,0,1,1,0,1,1,1};
int *s;
int j;
s=scramble(string);
for(j=0;j<=767;j++)
{
printf("%d",*(s+j));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -