⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 leishixian.cpp

📁 主要实现人员管理功能
💻 CPP
字号:
#include <iostream>
#include"Leidingyi.h"
using namespace std;

int Person::No=0;
int Person::Acount=0;

Person::Person()
{int i=0;
  while(i<22)
  {
   Name[i]=0;
   i++;
   //No=1;
   //Acount=0;
  }
}


void Person::AddNode(Node *m)
{
	Node* q=m;
	while(q->next!=NULL)
	{
		q=q->next;
	}
	Node zzh;
	Person people;
	//people.Name={0};
	q->next=new Node(zzh);
	
		if(q==NULL)
	    {
			cout<<"No enough memory!"<<endl;
		}
	q->next->next=NULL;
	cout<<"Input the name!"<<endl;
	cin>>people.Name;
	
	for(int i=0;i<22;i++)  
	{
		q->next->NName[i]=people.Name[i];
		
		
	}
	//Acount++;
	q->next->No=++No;
	
}

Node* Person::SearchName(Node *q,char name[22])
{
	int mark=1;
	int i=0;
	while(q->next!=NULL)
	{
		if(stricmp(q->next->NName,name)==0)
		{
			cout<<"Person's name is:";
			//for(i=0;i<22;i++)
			//if(q->next->NName[i]!=0)break;
        	cout<<q->next->NName<<endl;
			
			cout<<" Person's number is:"<<q->next->No<<endl;
			mark++;
			return q;
		}
		q=q->next;
	}
	if(mark==1)
	{return NULL;}
}

Node* Person::SearchNo(Node *q,int nNo)
{
	while(q->next!=NULL)
	{
		if(q->next->No==nNo)
		{
			cout<<"Person's name is:"<<q->next->NName<<endl<<"Person's number is:"<<q->next->No<<endl;
			return q;
		}
		q=q->next;
	}

}

void Person::DeleteName(Node *q,char name[22])
{
	Node *m,*n;
	m=SearchName(q,name);
	n=m->next->next;
	delete m->next;
	m->next=n;
    //Person::Acount--;//总人数减少

}

void Person::DeleteNo(Node *q,int number)
{
	Node *m,*n;
	m=SearchNo(q,number);
	n=m->next->next;
	delete m->next;
	m->next=n;
	//Person::Acount--;//总人数减少
}

void Person::ShowAllNode(Node *q)
{
	while(q->next!=NULL)
	{
		cout<<"Person's name is:"<<q->next->NName<<endl<<"Person's number is:"<<q->next->No<<endl;
        q=q->next;
	}
			

}
Person::Person(char* name)
{
  int i=0;
  while(i<20)
  {
   Name[i]=name[i];
   i++;
  }
}

⌨️ 快捷键说明

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