#include<iostream.h>
#include<math.h>
class List;
class item
{
public:
friend class List;
private:
item(int p=0,int s=0,int b=0,int l=0,int c=0){page=p;sign=s;block=b;locate=l;changesign=c;next=NULL;}
item *next;
int page;
int sign;
int changesign;
int block;
int locate;
};
class List
{
public:
List(int p=0,int s=0,int b=0,int l=0,int c=0){list=new item(p,s,b,l,c);}
int check(int p);
int insert(int p,int s,int b,int l);
void print();
int append(int p,int s,int b,int l);
int length();
int alternative(int k,int p);
void reverse();
private:
item *list;
item *end();
};
int List ::alternative(int k,int p)
{
int n,m;
item *pt=list,*pr=list;
for(int temp=1;temp<=k;temp++)
{
pt=pt->next;
}
cout<<endl;
n=pt->block;
cout<<"被调换的页的页号为:"<<pt->page<<" 该页所对应的修改标志位为:"<<pt->changesign<<endl;
cout<<"被调入的页的页号为:"<<p<<endl;
cout<<"*****************************************"<<endl;
cout<<"请输入被调入页的磁盘地址:";
cin>>m;
for(;pr;pr=pr->next)
{
if(pr->locate==m)
{
cout<<"该磁盘地址已存有数据,请选择另外的磁盘地址进行存储:";
cin>>m;
pr=list;
}
}
//cout<<"++++++++++++++++++++++++++++++++++"<<endl;
pt->locate=m;
pt->page=p;
return n;
}