generateinput.cpp

来自「这个是数据打孔重传程序的源代码」· C++ 代码 · 共 59 行

CPP
59
字号
/**********************************************/
/* Generator of input bits 
/* int * GenerateInputF(struct BasicParaS * ctrl)
/*      Written by: Ouyang Ziyue,
/*            Date: Jun 11th, 2007,
/*        Function: It randomly generates 0s and 1s to build a frame of length of K, the 0s and 1s
/*                  follow the uniform distribution.
/* Input parameter:
/*        The length of  information bits(K) is needed.
/* Output parameter:
/*        An INT set which includes all the info bits is returned.
/* Note:
/*        ctrl should be built before this function is called.
/**********************************************/

#include "parameter_sets.h"

int * GenerateInputF(struct BasicParaS * ctrl)
{
	//////////////////////////////////////////////////////////////////////////
	//Declaration
	int i;
	int * temp;
	temp = new int[ctrl->codeK];
	if(temp == NULL)
		exit(0);
	
	//////////////////////////////////////////////////////////////////////////
	//Generating
	for (i=0; i<ctrl->codeK; i++)
	{
		* (temp + i) = generate_binary_source();
	}

	//////////////////////////////////////////////////////////////////////////
	//DEBUG
#ifdef DEBUG
	printf("The input bits are ... \n");
	int j;
	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("%d ", *(temp+i));
		}
	}
	printf("\n");
#endif

	return temp;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?