// Dim.h: interface for the CDim class.
	//
	//////////////////////////////////////////////////////////////////////

	#if !defined(AFX_DIM1_H__738C0D53_52D5_11D4_A411_080009B45370__INCLUDED_)
	#define AFX_DIM1_H__738C0D53_52D5_11D4_A411_080009B45370__INCLUDED_

	#if _MSC_VER > 1000
	#pragma once
	#endif // _MSC_VER > 1000

	class CDim  
	{
	public:
		CDim();
		virtual ~CDim();

	public:
		static char **CDim::dim(int Lo,int Co,int Bt); //Assign 2 dimesion array, A[i][j]
		static char ***CDim::dim_3(int Gd, int Lo, int Co, int Bt); //Assign 3 dimension array, A[i][j][k]
		static void CDim::dimfree(char **pt);
		static void CDim::dimfree_3(char ***pt);
	};

	#endif // !defined(AFX_DIM1_H__738C0D53_52D5_11D4_A411_080009B45370__INCLUDED_)


	// Dim1.cpp: implementation of the CDim class.
	//
	//////////////////////////////////////////////////////////////////////

	#include "stdafx.h"
	#include "Dim.h"

	#ifdef _DEBUG
	#undef THIS_FILE
	static char THIS_FILE[]=__FILE__;
	#define new DEBUG_NEW
	#endif

	//////////////////////////////////////////////////////////////////////
	// Construction/Destruction
	//////////////////////////////////////////////////////////////////////

	CDim::CDim()
	{

	}

	CDim::~CDim()
	{

	}

	char **CDim::dim(int Lo,int Co,int Bt)
	{
		int i;
		char **pt_Lo,*pt_Dt;
		if((pt_Lo = (char **)calloc(Lo,sizeof(char *))) == NULL) {
			exit(4);
		}
		if((pt_Dt = (char *)calloc(Lo * Co, Bt)) == NULL) {
			exit(5);
		}
		for(i = 0; i < Lo ; i++) pt_Lo[i] = pt_Dt + i * Co * Bt;
		return pt_Lo;
	}

	void CDim::dimfree(char **pt)
	{
		free(*pt);
		free(pt);
	}

	void CDim::dimfree_3(char ***pt)
	{
		free(**pt);
		free(*pt);
		free(pt);
	}

	char ***CDim::dim_3(int Gd, int Lo, int Co, int Bt)
	{
		int i;
		char ***pt_Gd,**pt_Lo,*pt_Dt;
		pt_Dt = (char *)calloc(Gd * Lo * Co, Bt);
		pt_Lo = (char **)calloc(Gd * Lo,sizeof(char *));
		pt_Gd = (char ***)calloc(Gd, sizeof(char **));
		for(i = 0; i < Gd * Lo ; i++)
			  pt_Lo[i] = pt_Dt + i * Co * Bt;
		for(i = 0; i < Gd ; i++)
				pt_Gd[i] = pt_Lo + i * Lo ;
		return pt_Gd;
	}