2个回答
展开全部
呃
用什么编啊?
用什么编啊?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
/*LINK.cpp*/
#include "Link.h"
#include "node.h"
#include <iostream.h>
Link::Link()
{
head = NULL;
}
Link::~Link()
{
if (head == NULL)
return;
else
{
Node* pdel = head;
Node* ptemp = head;
do
{
ptemp = pdel->next;
delete pdel;
pdel = ptemp;
} while( pdel != head);
}
head = NULL;
}
void Link::insert(int number,int mima)//插入接点
{
Node* padd = new Node( number, mima);
if (head == NULL)
{
head = padd;
}
else
{
Node* p = head;
while (p->next != head)
p = p->next;
p->next = padd;
}
padd->next = head;
}
void Link::show()//输出接点
{
Node* p = head;
if ( p == NULL)
return;
do
{
cout<<p->number<<" ";
p = p->next;
} while(p != head);
cout<<endl;
}
void Link::del(Node *p)//删除接点
{
if (p!=NULL)
{
Node* pdel = p->next;
if (pdel!= NULL )
{
if (pdel == head)
head = pdel->next;
p->next = pdel->next;
delete pdel;
}
}
}
/*node.cpp*/
#include <iostream.h>
#include "Node.h"
Node::Node(int number,int mima)
{
next = NULL;
this->number = number;
this->mima = mima;
}
Node::~Node()
{
}
#include <iostream.h>
#include "link.h"
#include "node.h"
/*MAIN.CPP*/
void main()
{
Link l;
int num = 4;
int mima = 0;
int j = 1;
cout<<"输入元素个数:";
cin>>num;
if (num <=0 )
{
cout<<"元素个数最少为2"<<endl;
return;
}
for( int i=1; i<=num; i++)
{
cout<<"输入第"<<i<<"元素密码:";
cin>>mima;
l.insert( i,mima );
}
Node *p = l.head;
cout<<"输入第一个删除的密码:";
cin>>mima;
while( l.head != l.head->next)
{
l.show();
for( i=1; i<mima-1; i++)
{
p = p->next;
}
mima = p->next->mima;
l.del( p );
p=p->next;
}
l.show();
}
#include "stdlib.h"
#include "iostream.h"
#include "stdio.h"
class ysfpass
{
public:
int num;
int pass;
ysfpass *next;
ysfpass *pre;
ysfpass(int i,int j)
{
num=i;pass=j;}
ysfpass()
{}
};
void yyssff(ysfpass *y,int number,int password)
{
int xuhao=1;
while(number!=0)
{
if(xuhao==password)
{
cout<<"第";cout<<number;cout<<'\n';
password=y->pass;
xuhao=1;
number--;
y->pre->next=y->next;
y->next->pre=y->pre;
y=y->next;
}
y=y->next;
xuhao++;
}
}
void main()
{char m_num,m_pass;
cin>>m_num;
cin>>m_pass;
ysfpass* curr;ysfpass* pre;
ysfpass* head=new ysfpass(m_num-48,m_pass-48);
pre=curr=head;
while(true)
{cin>>m_num;
if(m_num=='a')
break;
cin>>m_pass;
curr=new ysfpass(m_num-48,m_pass-48);
curr->pre=pre;
pre->next=curr;
pre=curr;
}
head->pre=curr;
curr->next=head;
cout<<"输入密码";
int password;
cin>>password;
yyssff(head,7,password);
}
#include "Link.h"
#include "node.h"
#include <iostream.h>
Link::Link()
{
head = NULL;
}
Link::~Link()
{
if (head == NULL)
return;
else
{
Node* pdel = head;
Node* ptemp = head;
do
{
ptemp = pdel->next;
delete pdel;
pdel = ptemp;
} while( pdel != head);
}
head = NULL;
}
void Link::insert(int number,int mima)//插入接点
{
Node* padd = new Node( number, mima);
if (head == NULL)
{
head = padd;
}
else
{
Node* p = head;
while (p->next != head)
p = p->next;
p->next = padd;
}
padd->next = head;
}
void Link::show()//输出接点
{
Node* p = head;
if ( p == NULL)
return;
do
{
cout<<p->number<<" ";
p = p->next;
} while(p != head);
cout<<endl;
}
void Link::del(Node *p)//删除接点
{
if (p!=NULL)
{
Node* pdel = p->next;
if (pdel!= NULL )
{
if (pdel == head)
head = pdel->next;
p->next = pdel->next;
delete pdel;
}
}
}
/*node.cpp*/
#include <iostream.h>
#include "Node.h"
Node::Node(int number,int mima)
{
next = NULL;
this->number = number;
this->mima = mima;
}
Node::~Node()
{
}
#include <iostream.h>
#include "link.h"
#include "node.h"
/*MAIN.CPP*/
void main()
{
Link l;
int num = 4;
int mima = 0;
int j = 1;
cout<<"输入元素个数:";
cin>>num;
if (num <=0 )
{
cout<<"元素个数最少为2"<<endl;
return;
}
for( int i=1; i<=num; i++)
{
cout<<"输入第"<<i<<"元素密码:";
cin>>mima;
l.insert( i,mima );
}
Node *p = l.head;
cout<<"输入第一个删除的密码:";
cin>>mima;
while( l.head != l.head->next)
{
l.show();
for( i=1; i<mima-1; i++)
{
p = p->next;
}
mima = p->next->mima;
l.del( p );
p=p->next;
}
l.show();
}
#include "stdlib.h"
#include "iostream.h"
#include "stdio.h"
class ysfpass
{
public:
int num;
int pass;
ysfpass *next;
ysfpass *pre;
ysfpass(int i,int j)
{
num=i;pass=j;}
ysfpass()
{}
};
void yyssff(ysfpass *y,int number,int password)
{
int xuhao=1;
while(number!=0)
{
if(xuhao==password)
{
cout<<"第";cout<<number;cout<<'\n';
password=y->pass;
xuhao=1;
number--;
y->pre->next=y->next;
y->next->pre=y->pre;
y=y->next;
}
y=y->next;
xuhao++;
}
}
void main()
{char m_num,m_pass;
cin>>m_num;
cin>>m_pass;
ysfpass* curr;ysfpass* pre;
ysfpass* head=new ysfpass(m_num-48,m_pass-48);
pre=curr=head;
while(true)
{cin>>m_num;
if(m_num=='a')
break;
cin>>m_pass;
curr=new ysfpass(m_num-48,m_pass-48);
curr->pre=pre;
pre->next=curr;
pre=curr;
}
head->pre=curr;
curr->next=head;
cout<<"输入密码";
int password;
cin>>password;
yyssff(head,7,password);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询