⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 定义变尺寸矢量和数组.txt

📁 定义变尺寸矢量和数组, 定义变尺寸矢量和数组
💻 TXT
字号:
double * vector(int nl,int nh)
{
/* allocate the array arranged with one row */
/* {IN} nl : the begin number of the array*/
/* {IN} nh : the end number of the array*/
/* {OUT} double * : the pointer which point the array's address*/

	double *v;
	v=(double *)malloc((nh-nl+1+1)*sizeof(double));
	if (v==NULL) printf("Allocation failure in vector() \n");
	return v;
}


void free_vector(double *v)
{
	free(v);
}


double ** matrix(int rownl,int rownh,int colnl,int colnh)
{
/* allocate the matrix with subscript range with M[rownl...rownh][colnl...colnh] */
/* {IN} rownl : the begin number of the matrix in rows*/
/* {IN} rownh : the end number of the array in rows*/
/* {IN} colnl : the begin number of the array in cols*/
/* {IN} colnh : the end number of the array in cols*/
/* {OUT}** matrix: the head address of the matrix */


	int i;
	double **m;

	m=(double **)malloc((rownh-rownl+1+1)*sizeof(double *));
	if (m==NULL) printf("Allocation failure in matrix() for row\n");

	for (i=rownl;i<=rownh;i++)
	{
		m[i]=(double *)malloc((colnh-colnl+1+1)*sizeof(double));
		if (m[i]==NULL) printf("Allocation failure in matrix() for column\n");
	}
	return m; /* return the head of m */
}


void free_matrix(double **m,int rownl,int rownh)
{
	int i;
	for (i=rownl;i<=rownh;i++)
	{
	free(m[i]);
	}
	free(m);

}

⌨️ 快捷键说明

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