?? mylist.cpp
字號:
#include"mylist.h"
#include<iostream>
using namespace std;
void List::addFromHead(Word *nod)
{
size++;
if(nod!=NULL)
{
nod->next=NULL;
}
if(head==NULL)
{
head=tail=nod;
}
else
{
nod->next=head;
head=nod;
}
}
void List::addFromTail(Word *nod)
{
size++;
if(nod!=NULL)
{
nod->next=NULL;
}
if(tail==NULL)
{
head=tail=nod;
}
else
{
tail->next=nod;
tail=nod;
}
}
Word* List::getFromHead()
{
if(head==NULL)
{
return NULL;
}
size--;
Word *tmp;
tmp=head;
head=head->next;
return tmp;
}
Word* List::getFromTail()
{
if(tail==NULL)
return NULL;
size--;
Word *tmp;
if(head==tail)
{
tmp=head;
head=tail=NULL;
return tmp;
}
for(tmp=head;tmp!=NULL&&tmp->next!=tail;tmp=tmp->next);
Word* temp=tail;
tail=tmp;
return temp;
}
void List::printAll()
{
if(head==NULL)
{
cout<<"the list is empty!";
exit(0);
}
Word *tmp;
for(tmp=head;tmp!=NULL;tmp=tmp->next)
{
cout<<tmp->character<<"/";
if((tmp->flag==11)|(tmp->flag==21))
cout<<"No."<<endl;
else if((tmp->flag==12)|(tmp->flag==22))
cout<<"p"<<endl;
else if((tmp->flag==13)|(tmp->flag==23))
cout<<"c"<<endl;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -