-
int List::LocateElem(Node *pNode) { Node *currentNode = m_pList; for(int i=0;currentNode->next!=NULL;i++) { currentNode = currentNode->next; if(currentNode->data==pNode->data) { return i; } } return -1; }查看全部
-
for(int k=0;k<=i;k++) { currentNode = currentNode->next; }查看全部
-
Node *currentNode = m_pList; for(int k=0;k<i;k++) { currentNode = currentNode->next; }//(i-1)th Node Node *currentNodeBefore = currentNode; currentNode = currentNode->next;//i-th Node查看全部
-
線性表分為 順序表和鏈表查看全部
-
int temp=0;查看全部
-
動手實踐,事倍功半查看全部
-
線性表是n個數據元素的有限序列查看全部
-
循環鏈表:尾指針指向頭指針所在的數據域查看全部
-
ListDelete函數中pNode參數可以不用實現這個功能查看全部
-
創建了兩個List類型對象:*Temp與*newNode,第一個用來臨時存儲第一個節點(位置)(即m_pList->next);第二個是用來代替傳入的形參查看全部
-
Node *temp=m_pList->next;即m_pList->next表示m_pList下一個節點的地址,整體上這條語句是為Node類型對象指針初始化,執行后,*temp即m_pList下一個節點查看全部
-
m_pList指向一個Node類型的對象,即對象指針的一種情形,因此可用->符號來訪問對象所含有的數據成員。查看全部
-
Node*p即一個指向Node類型數據的指針查看全部
-
一邊看一邊敲 #include <iostream> #include <stdlib.h> #include "List.h" using namespace std; /*線性表*/ int menu() { cout<<"功能菜單"<<endl; cout<<"1 新建聯系人"<<endl; cout<<"2 刪除聯系人"<<endl; cout<<"3 瀏覽通訊錄"<<endl; cout<<"4 退出通訊錄"<<endl; cout<<"請輸入:"; int order=0; cin>>order; return order; } void creatperson(List *pList) { Node node; Person person; cout<<"輸入用戶姓名:"; cin>>person.name; cout<<"輸入電話號碼:"; cin>>person.phone; node.data=person; pList->ListInsertTail(&node); } int main() { int userorder=0; List *pList=new List(); while(userorder!=4) { userorder=menu(); switch(userorder) { case 1: cout<<"用戶指令-------》新建聯系人"<<endl; creatperson(pList); break; case 2: cout<<"用戶指令-------》刪除聯系人"<<endl; break; case 3: cout<<"用戶指令-------》瀏覽通訊錄"<<endl; pList->ListTravers(); break; case 4: cout<<"用戶指令-------》退出通訊錄"<<endl; break; } } delete pList; pList=NULL; system("pause"); return 0; } //List.h #ifndef LIST_H #define LIST_H #include "Node.h"查看全部
-
對<<和 ==兩個運算符進行重載查看全部
舉報
0/150
提交
取消