initiali.c

来自「数据挖掘Apriori算法的java源码」· C语言 代码 · 共 37 行

C
37
字号
/* file: initiali.c
 *
 * purpose: create an initial population of structures,
 * and initalize some performance variables.
 * This is called at the start of each experiment.
 */

#include <stdlib.h>
#include <time.h>


void
initiali(int **Popu,int p_size,int len)
{
	int 	i;
	int	j;
	double 	prob;
	time_t  t;

	/* generate the initialzied population */
	srand((unsigned) time(&t));

	for (i=0;i<p_size;i++)
	{
		for (j=0;j<len;j++)
		{
			prob=(1.0*random(1000))/1000;
			if (prob>0.5)
				Popu[i][j]=1;
			else
				Popu[i][j]=0;
		}
	}
}


⌨️ 快捷键说明

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