?? graph.cpp
字號(hào):
// graph.cpp: implementation of the graph class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "graph.h"
#ifndef NULL
#define NULL 0
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
graph::graph()
{
head=&midhead;
len=0;
head->next=NULL;
cur=head;
next=head;
}
graph::~graph()
{
}
void graph::addnode(node *nd)
{
cur->next=nd;
len++;
cur=nd;
}
node * graph::delnode(node *nd)
{
node *temp;
temp=head;
while(temp->next!=nd&&temp->next!=NULL)
temp=temp->next;
if(temp->next==NULL)
return NULL;
else
{
if(temp->next->next==NULL)
cur=temp;
temp->next=temp->next->next;
len--;
return nd;
}
}
bool graph::find(node *nd)
{
node *temp;
temp=head;
while(temp->next!=nd&&temp->next!=NULL)
temp=temp->next;
if(temp->next==NULL)
return 0;
else
return 1;
}
int graph::getlength()
{
return len;
}
node * graph::getnext()
{
if(next!=NULL)
{
next=next->next;
return next;
}
else
return NULL;
}
void graph::reset()
{
next=head;
}
node * graph::delnode(int num)
{
node *temp,*res;
temp=head;
while(temp->next->number!=num&&temp->next!=NULL)
temp=temp->next;
if(temp->next==NULL)
return NULL;
else
{
if(temp->next->next==NULL)
cur=temp;
res=temp->next;
temp->next=temp->next->next;
len--;
return res;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -