📄 main.c
字号:
#include"main.h"
//#ifndef GFMM_KK_B0
//#define GFMM_KK_B0
//#define mm 8
//#define nn 255
//#define kk 243
//#define tt 6
//#define b0 120
//#define nn_short 31
//#define kk_short 19
//#endif
//#include "RS_En.c"
//#include "RS_De.c"
/*此次设计没有用到缩短码,所以|RSDemain和RSEnmain都没有用。*/
#include"stdio.h"
main()
{
int i=0,flag;
int indata[243],cb[12],codedata[255],dedata[243];
FILE *fp;
for(i=0;i<243;i++) indata[i] = i;
encode_rs(indata,cb);/*indata为信息数据 cb为检错数据*/
for(i=0;i<12;i++) codedata[i] = cb[i];/*此时 codedata 为编码后的数据*/
for(i=12;i<255;i++) codedata[i] = indata[i-12];
#define error0
#ifdef error0
// if((fp=fopen("dout.txt","w"))==NULL)
// {
// printf("can't open this file\n");
// exit(0);
// }
// fprintf(fp,"EnCode is:\n");
// for(i=0;i<255;i++)
// {
// fprintf(fp,"%02x ",codedata[i]);
// }
flag=decode_rs(codedata);/*解码后的数据*/
// fprintf(fp,"\nDeCode is:\n");
for(i=0;i<243;i++)
{
dedata[i]=codedata[i+12];
// fprintf(fp,"%02x ",dedata[i]);
}
// fprintf(fp,"\nflag is: %d \n",flag);
fclose(fp);
// for(i=0;i<255;i++)
// {
// printf("%d,",codedata[i]);
// }
#endif
// #define error3
#ifdef error3
if((fp=fopen("dout3.txt","w"))==NULL)
{
// printf("can't open this file\n");
exit(0);
}
// fprintf(fp,"EnCode is:\n");
// for(i=0;i<255;i++)
// {
// fprintf(fp,"%02x ",codedata[i]);
// }
codedata[46] = 0X1D;
codedata[44] = 0x1F;
codedata[45] = 0x1E;
/*对编码后的数据加错码*/
// fprintf(fp,"Eerrocode is:\n");
// for(i=0;i<255;i++)
// {
// fprintf(fp,"%02x ",codedata[i]);
// }
flag=decode_rs(codedata);/*解码后的数据*/
// fprintf(fp,"\nDeCode is:\n");
for(i=0;i<243;i++)
{
dedata[i]=codedata[i+12];
// fprintf(fp,"%02x ",dedata[i]);
}
// fprintf(fp,"\nflag is: %d \n",flag);
fclose(fp);
#endif
// #define error6
#ifdef error6
if((fp=fopen("dout6.txt","w"))==NULL)
{
// printf("can't open this file\n");
exit(0);
}
// fprintf(fp,"EnCode is:\n");
// for(i=0;i<255;i++)
// {
// fprintf(fp,"%02x ",codedata[i]);
// }
// for(i=0;i<255;i++)
// {
// printf("%d,",codedata[i]);
// }
codedata[46] = 0X1D;
codedata[44] = 0x1F;
codedata[45] = 0x1E;
codedata[47] = 0x1c;
codedata[48] = 0x1b;
codedata[49] = 0x1a;
/*对编码后的数据加错码*/
fprintf(fp,"Eerrocode is:\n");
// for(i=0;i<255;i++)
// {
// fprintf(fp,"%02x ",codedata[i]);
// }
flag=decode_rs(codedata);/*解码后的数据*/
// fprintf(fp,"\nDeCode is:\n");
// for(i=0;i<255;i++)
// {
// fprintf(fp,"%02x ",codedata[i]);
// }
// fprintf(fp,"\nflag is: %d \n",flag);
fclose(fp);
#endif
// #define error7
#ifdef error7
if((fp=fopen("dout7.txt","w"))==NULL)
{
// printf("can't open this file\n");
exit(0);
}
// fprintf(fp,"EnCode is:\n");
// for(i=0;i<255;i++)
// {
// fprintf(fp,"%02x ",codedata[i]);
// }
// for(i=0;i<255;i++)
// {
// printf("%d,",codedata[i]);
// }
codedata[46] = 0X1D;
codedata[44] = 0x1F;
codedata[45] = 0x1E;
codedata[47] = 0x1c;
codedata[48] = 0x1b;
codedata[49] = 0x1a;
codedata[50] =6;
/*对编码后的数据加错码*/
// fprintf(fp,"Eerrocode is:\n");
// for(i=0;i<255;i++)
// {
// fprintf(fp,"%02x ",codedata[i]);
// }
flag=decode_rs(codedata);/*解码后的数据*/
// fprintf(fp,"\nDeCode is:\n");
// for(i=0;i<255;i++)
// {
// fprintf(fp,"%02x ",codedata[i]);
// }
// fprintf(fp,"\nflag is: %d \n",flag);
fclose(fp);
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -