📄 generateinput.cpp
字号:
#include "parameter_sets.h"
const int threshold = RAND_MAX/2;
int * GenerateInputF(struct BasicParaS * ctrl)
{
int i,j;
int * temp = new int[ctrl->codeK]; //定义一个有ctrl->codeK个元素的数组
if (temp == NULL)
exit(EXIT_FAILURE);
srand((unsigned)time(NULL));
for(i=0; i<ctrl->codeK; i++)
{
if (rand() < threshold)
{
*(temp+i) = 0;
}
else
{
*(temp+i) = 1;
}
}
if (ctrl->mode == 1)
{
printf("The input bits are ..\n");
for (i=0; i<ctrl->codeK/24; i++)
{
for (j=0; j<24; j++)
{
printf("%2d", *(temp+i*24+j));
}
printf("\n");
}
if (ctrl->codeK%24)
{
for (i=(ctrl->codeK/24)*24; i<ctrl->codeK; i++)
{
printf("%2d", *(temp+i));
}
printf("\n");
}
}
return temp;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -