第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

通訊錄,為什么不能用?急

/*Person.h*/
#ifndef?PERSON_H
#define?PERSON_H
#include<string>
#include<ostream>
using?namespace?std;

class?Person
{
	friend?ostream?&operator<<(ostream?&out,?Person?&person);//友元函數(shù)輸出運(yùn)算符的重載
public:
	string?name;
	string?phone;
	Person?&operator=(Person?&person);
	bool?operator==(Person?&person);
};
#endif
/*Person.cpp*/
/*List.h*/
#ifndef?LIST_H
#define?LIST_H

#include"Node.h"
class?List
{
public:
	List();
	~List();
	void?ClearList();
	bool?ListEmpty();
	int?ListLength();
	bool?GetElem(int?i,?Node?*pNode);
	int?LocateElem(Node?*pNode);
	void?ListTraverse();
	bool?ListInsert(int?i,?Node?*pNode);
	bool?ListDelete(int?i,?Node?*pNode);
	bool?ListInsertHead(Node?*pNode);
	bool?ListInsertTail(Node?*pNode);
private:
	Node?*m_plist;
	int?m_ilength;
};

#endif
/*List.cpp*/
#include"List.h"
#include<iostream>
using?namespace?std;

List::List()
{
	m_plist?=?new?Node;
	//m_plist->data=0;
	m_plist->next?=?NULL;
	m_ilength?=?0;
}
List::~List()
{
	ClearList();
		delete?m_plist;
	m_plist?=?NULL;
}

void?List::ClearList()//清空
{
	Node?*currentNode?=?m_plist->next;
	while?(currentNode?!=?NULL)
	{
		Node?*temp?=?currentNode->next;
		delete?currentNode;
		currentNode?=?temp;
	}
	m_plist->next?=?NULL;
}

bool?List::ListEmpty()
{
	if?(m_ilength?==?0)
	{
		return?true;
	}
	else
	{
		return?false;
	}
	//return?m_ilength==0?true:false;
}

int?List::ListLength()
{
	return?m_ilength;
}

bool?List::GetElem(int?i,?Node?*pNode)//獲取指定元素
{
	if?(i<0?||?i?>=?m_ilength)
	{
		return?false;
	}
	Node?*currentNode?=?m_plist;
	Node?*currentNodeBefore?=?NULL;

	for?(int?k=0;?k?<=?i;?k++)
	{
		currentNodeBefore?=?currentNode;
		currentNode?=?currentNode->next;
	}
	pNode->data?=?currentNode->data;
	return?true;
}

int?List::LocateElem(Node?*pNode)//尋找第一個(gè)滿足e的數(shù)據(jù)元素的位序
{
	Node?*currentNode?=?m_plist;
	int?count?=?0;
	while?(currentNode->next?!=?NULL)
	{
		currentNode?=?currentNode->next;
		if?(currentNode->data?==?pNode->data)
		{
			return?count;
		}
		count++;
	}
	return?-1;
}

void?List::ListTraverse()//遍歷
{
	Node?*currentNode?=?m_plist;
	while?(currentNode->next?!=?NULL)
	{
		currentNode?=?currentNode->next;
		currentNode->printNode();
	}
}

bool?List::ListInsert(int?i,?Node?*pNode)//在第i個(gè)位置插入元素
{
	if?(i<0?||?i>m_ilength)
	{
		return?false;
	}
	Node?*currentNode?=?m_plist;
	for?(int?k?=?0;?k<i;?k++)
	{
		currentNode?=?currentNode->next;
	}
	Node?*newNode?=?new?Node;
	if?(newNode?==?NULL)
	{
		return?false;
	}
	newNode->data?=?pNode->data;
	newNode->next?=?currentNode->next;
	currentNode->next?=?newNode;
	return?true;
}

bool?List::ListDelete(int?i,?Node?*pNode)//刪除第i個(gè)位置的元素
{
	if?(i<0?||?i?>=?m_ilength)
	{
		return?false;
	}
	Node?*currentNode?=?m_plist;
	Node?*currentNodeBefore?=?NULL;

	for?(int?k=0;?k?<=?i;?k++)
	{
		currentNodeBefore?=?currentNode;
		currentNode?=?currentNode->next;
	}
	currentNodeBefore->next?=?currentNode->next;
	pNode->data?=?currentNode->data;
	delete?currentNode;
	currentNode?=?NULL;
	m_ilength--;
	return?true;
}
bool?List::ListInsertHead(Node?*pNode)
{
	Node?*temp?=?m_plist->next;
	Node?*newNode?=?new?Node;
	if?(newNode?==?NULL)
	{
		return?false;
	}
	newNode->data?=?pNode->data;
	m_plist->next?=?newNode;
	newNode->next?=?temp;
	m_ilength++;
	return?true;
}
bool?List::ListInsertTail(Node?*pNode)
{
	Node?*currentNode?=?m_plist;
	while?(currentNode->next?!=?NULL)
	{
		currentNode?=?currentNode->next;
	}
	Node?*newNode?=?new?Node;
	if?(newNode?==?NULL)
	{
		return?false;
	}
	newNode->data?=?pNode->data;
	newNode->next?=?NULL;
	currentNode->next?=?new?Node;
	m_ilength++;
	return?true;
}
/*Node.h*/
#ifndef?NODE_H
#define?NODE_H

#include"Person.h"

class?Node
{
public:
	Person?data;
	Node?*next;
	void?printNode();
};
#endif
/*Node.cpp*/
#include"Node.h"
#include<iostream>
using?namespace?std;

void?Node::printNode()
{
	cout?<<?data?<<?endl;
}
/*demo.cpp*/
#include<stdlib.h>
#include"List.h"
#include<iostream>
using?namespace?std;
int?main(void)
{
	Node?node1;
	node1.data.name?=?"weqrwq";
	node1.data.phone?=?"1312556";
	Node?node2;
	node2.data.name?=?"wq";
	node2.data.phone?=?"1356";
	List?*pList?=?new?List();
	pList->ListInsertTail(&node1);
	pList->ListInsertTail(&node2);
	pList->ListTraverse();
	delete?pList;
	pList?=?NULL;
	system("pause");
	return?0;
}


正在回答

1 回答

把你的錯(cuò)誤提示發(fā)一下

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

通訊錄,為什么不能用?急

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)