📄 operate.h
字号:
Status Operate(int j)
{
int flag,x;
Result V;
if(j==0)
{
cout<<"退出本系统"<<endl;
return OK;
}
else
{
cout<<"输入书号:";
cin>>x;cout<<endl;
V=SearchBTree(T,x);
switch(j){
case 1:
cout<<"新书入库"<<endl;
if(V.tag==1)
{
V.pt->recptr[V.i]->total+=A;
V.pt->recptr[V.i]->now+=A;
}
else
{
Record *r;
r=new Record;
r->num=x;
r->now=A;
r->total=A;
r->next=NULL;
InsertBTree(T,x,r,V.pt,V.i);
}
Print(T,40);
break;
case 2:
cout<<"清书出库"<<endl;
if(V.tag==0)
{
cout<<endl<<"=========================================================================="<<endl<<endl;
cout<<"书库没有这种书,请再次选择操作"<<endl;
}
else
DeleteBTree(T,x,V.pt->recptr[V.i],V.pt,V.i);
Print(T,40);
break;
case 3:
if(V.tag==1)
{
if(V.pt->recptr[V.i]->now>0)
{
Lender *L1,*L2;
L1=new Lender;
L1->next=NULL;
cout<<"借者书证号:";
cin>>L1->card;cout<<endl;
cout<<"归还日期:";
cin>>L1->time;cout<<endl;
if(V.pt->recptr[V.i]->next==NULL)
V.pt->recptr[V.i]->next=L1;
else
{
L2=V.pt->recptr[V.i]->next;
while(L2->next!=NULL)
L2=L2->next;
L2->next=L1;
}
cout<<"借出"<<x<<"号书一本"<<endl<<endl;
V.pt->recptr[V.i]->now-=1;
}
else
cout<<"此种书已借完"<<endl<<endl;
}
else
cout<<"没有这种书"<<endl<<endl;
break;
case 4:
if(V.tag==1&&V.pt->recptr[V.i]->now<V.pt->recptr[V.i]->total)
{
Lender *L1,*L2;
char cards[20];
L1=V.pt->recptr[V.i]->next;
cout<<"还书者书证号:";
cin>>cards;
cout<<endl;
while(L1!=NULL)
{
L2=L1;
if(!strcmp(L1->card,cards))
{
L2->next=L1->next;
cout<<"还"<<x<<"号书一本"<<endl;
V.pt->recptr[V.i]->now+=1;
break;
}
else
L1=L1->next;
}
if(L1==NULL)cout<<"输入有误"<<endl<<endl;//书证号与所借的书不匹配
}
else
cout<<"输入有错"<<endl<<endl; //书库中不存在此类书
break;
default:break;
}
cout<<endl<<"=========================================================================="<<endl<<endl;
cout<<"请选择下一步操作"<<endl<<endl;
cout<<"flag:";
cin>>flag;
cout<<endl;
Operate(flag);return OK;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -