pattern.cpp

来自「vc++ study」· C++ 代码 · 共 60 行

CPP
60
字号
// Pattern.cpp: implementation of the CPattern class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "IsoData.h"
#include "Pattern.h"

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

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

CPattern::CPattern(int n)
{
	N = n;
	int i;	
	struct PatternElement * ptemp1,* ptemp2;
	ptemp1 = new struct PatternElement;
	pPatternElementHead = ptemp1;
	ptemp2 = ptemp1;

	for (i=1;i<=N;i++)
	{	
		ptemp2->next = ptemp1;
		ptemp2 = ptemp1;
		if (i!=N)
			ptemp1 = new struct PatternElement;
		else 
			ptemp1 = NULL;
	}

		
}

CPattern::~CPattern()
{
	int i;
	int j;
	struct PatternElement * ptemp1;
	ptemp1 = pPatternElementHead;
	for (j=1;j<=N-1;j++)
	{
		for (i=1;i<=N-j;i++)
		{
			ptemp1 = ptemp1->next;
		}
		delete ptemp1;
	}
	delete pPatternElementHead;
	

}

⌨️ 快捷键说明

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