admin管理员组文章数量:1516870
#include <iostream>
using namespace std;
template <class t>
struct node
{
t data;
node <t> *next;
};
template <class t>
class list
{
public:
list();
list(t a[],int n);
list(t a[],int n,int weicha);
void print();
t weizhi(int x);
t zhi(int x);
void JudgeZeng();
node <t> *first;
int l;
};
template <class t>
list<t>::list()
{
first =new node<t>;
first->next=NULL;
}
template <class t>
list<t>::list(t a[],int n)
{
first =new node<t>;
first->next=NULL;
node <t> *s;
for(int i=0; i<n; i++)
{
s=new node<t> ;
s->data=a[i];
s->next =first->next;
first->next=s;
}
}
template <class t>
list<t>::list(t a[],int n,int weicha)
{
node<t> *s,*r;
first =new node<t>;
r=first;
for (int i=0; i<n; i++)
{
s=new node<t>;
s->data=a[i];
r->next =s;
r=s;
}
r->next=NULL;
l=n;
}
template <class t>
void list<t> ::print ()
{
node <t> *p;
p=first->next;
while (p!=NULL)
{
cout<<p->data<<" ";
p=p->next;
}
}
template <class t>
t list <t>::zhi(int x)
{
node <t> *p,*q;
p=first->next;
int k=1;
while (p!=NULL&&x!=p->data)
{
p=p->next;
k++;
}
if(p==NULL||p->next==NULL)
cout<<"Error";
else
{
int j=0;
p=first;
while (p!=NULL&&j<k-1)
{
p=p->next;
j++;
}
q=p->next;
p->next=q->next;
delete q;
print();
}
}
template <class t>
t list <t>::weizhi(int x)
{
node <t> *p,*q;
p=first;
int j=0;
while (p!=NULL&&j<x-1)
{
p=p->next;
j++;
}
if(x<=0||p==NULL)
cout<<"Error";
else
{
q=p->next;
p->next=q->next;
delete q;
print();
}
}
template <class t>
void list<t>::JudgeZeng()
{
node<t>* p = first->next, * q;
if (p)
{
while (p->next)
{
q = p->next;
if (q->data > p->data)
p = q;
else
cout << "No";
}
}
cout << "Yes";
}
int main()
{
int a1[100];
int a2[100];
int t,x;
int i=0;
while (cin>>t&&t)
{
a1[i]=t;
i++;
}
list <int> a(a1,i,1);
i=0;
while (cin>>t&&t)
{
a2[i]=t;
i++;
}
list <int> b(a2,i);
cin>>x;
int y;
cin>>y;
a.print();
cout<<endl;
b.print();
cout<<endl;
a.zhi(x);
cout<<endl;
a.weizhi(y);
cout<<endl;
a.JudgeZeng();
}版权声明:本文标题:揭秘OpenJudge中的Flash中心:Runtime Error如何处理? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.betaflare.com/biancheng/1770688531a3257429.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论