dbg.cpp

来自「文本相似度比较```很好的`」· C++ 代码 · 共 81 行

CPP
81
字号
#include <iostream>
#include <string>


using namespace std;

typedef struct ListNode
{
	int m_Content;
	ListNode * Next;	
}Node;

// Create a new node
Node * CreateNode(int Content)
{
	Node * a = new Node;
	a->m_Content = Content;
	a->Next = NULL;
	return a;
}

// Create a list
Node * CreateList(int a)
{
	Node * header = NULL;
	Node * cur;
	for (int i = 0; i < a; i++)
	{
		// Create a new node
		Node * a = CreateNode(i);
		if (header == NULL)
		{
			cur = header = a;
		}
		else
		{
			cur->Next = a;
			cur = cur->Next;
			
		}
	}

	return header;
}

//Free the list
void FreeList(Node * head)
{
	Node * cur = head->Next;
	Node * pre = head;

	while (cur != NULL)
	{
		delete pre;
		pre = cur;
		cur = cur->Next;
	}
}

void PrintNode(Node * hd)
{
	Node * header = hd;
	while(header != NULL)
	{
		cout << header->m_Content << endl;
		header = header->Next;
	}
}

int main()
{
	int a;
	cin >> a;
	Node * t = CreateList(a);

	PrintNode(t);

	FreeList(t);

	return 0;
}

⌨️ 快捷键说明

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