mylist.cpp

来自「链表实验」· C++ 代码 · 共 72 行

CPP
72
字号

#include "stdafx.h"
#include <stdio.h>
#include "MyList.h"

void MyList::add(CString na,CString ag,CString st,CString te,char s[20])
{
	if(tail!=0)
	{
		tail->next=new Node(na,ag,st,te,s);
		tail=tail->next;
	}
	else
		head=tail=new Node(na,ag,st,te,s);
	   tail->next=head;
	
}

/*Node* MyList::search(CString name)
 {
 Node *p;
 p=head;
 if(p==NULL)return 0;
 while(p->name!=name)
 {
	 p=p->next;
    if(p==head)return 0;
 }
 return p;
 }


Node* MyList::delet(CString na)
{
	if(head!=0)
		if(head==tail&&na==head->name)
		{
			delete head;
			head=tail=0;
			return 0;
		}
	    else 
			if(na==head->name)
		{
			Node *temp=head->next;
			head=head->next;
			tail->next=head;
			delete temp;
			return head;
		}
	    else
		{
			Node *pred,*temp;
			for(pred=head,temp=head->next;temp!=tail&&!(na==temp->name);pred=pred->next,temp=temp->next);
				if(temp!=tail)
				{
					pred->next=temp->next;
					delete temp;
					return pred->next;
				}
				if(na==temp->name)
				{
				tail=pred;
				tail->next=head;
				delete temp;
				return pred->next;
				}
		}
		return 0;
}*/

⌨️ 快捷键说明

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