13
cout<
temp->next=head->next; temp->pre=head;
if (head->next!=NULL) head->next->pre=temp; head->next=temp; write_to_file();
cout< void search_delete(int x) //查找及对信息作出修改 { node *p,*q,*r; wait *tempw,*tempw2,*tempw3; int step=1,t1,t2,i; char ch; p=new node; tempw=new wait; tempw2=new wait; tempw3=new wait; q=head1; cout< cout< q=q->next; if ( (q!=NULL) && (comp(q,p)) ) { cout< q->date=q->plane; cout<<\ cout<<\ cout< cout<<\删除该纪录 ? [Y/N] \ cin>>ch; 14 if (ch=='Y' || ch=='y') { t1=q->plane; t2=q->seat; a[t1].seat[t2]=0; a[t1].seat[0]--; r=q;q=q->pre; r->pre->next=r->next; if(r->next!=NULL) r->next->pre=r->pre; delete(r); cout<<\记录删除成功 ! ****\ write_to_file(); tempw=wait_head; for(i=0;i tempw=tempw->next; if(tempw==NULL) break; if((tempw->plane==t1) && (tempw->seat==t2)) { strcpy(tempw3->name,tempw->name); strcpy(tempw3->phone,tempw->phone); cout< if(tempw->plane==1) add_information(head1,1,tempw->seat); if(tempw->plane==2) add_information(head2,2,tempw->seat); if(tempw->plane==3) add_information(head3,3,tempw->seat); tempw2=tempw->pre; tempw2->next=tempw->next; if(tempw->next==NULL) wait_end=tempw2; else tempw->next->pre=tempw2; delete(tempw); wait_head->count--; write_to_file(); cout< 15 { if (q==NULL) { step++; if(step==2) q=head2; if(step==3) q=head3; if(step==4) {cout< bool comp(node *x,node *y)//信息查找时对姓名的判断操作 { node *p,*q; int i,j,k; p=x; q=y; i=j=0; do { while ( (p->name[i] != q->name[j]) && (p->name[i] != '\\0') ) i++; if (p->name[i] == '\\0') {return(false);break;} else { k=i; while ( (p->name[k] == q->name[j]) && (q->name[j]!='\\0') ) {k++;j++;} if (q->name[j]=='\\0') return(true); else { j=0; i++; } } }while( (q->name[j]!='\\0') && (p->name[i] != '\\0') ); return(false); } void write_to_file()//程序中各主要文件操作的调用子函数,负责文件的读取与记录。 { FILE *fp; int i,j; int x[m]; node *p; wait *tempw; 16 tempw=new wait; tempw=wait_head; fp=fopen(\ for (i=1;i<=m-1;i++) { fwrite(&a[i],sizeof(piao),1,fp); } fclose(fp); fp=fopen(\ x[0]=0;x[1]=a[1].seat[0]; for(i=0,j=1;j<=m-1;j++) {i=i+a[j].seat[0];x[j]=a[j].seat[0]+x[j-1];} j=1;p=head1->next; for(j=1;j<=i;j++) { if(j==x[1]+1) p=head2->next; if(j==x[2]+1) p=head3->next; if(p==NULL)break; fwrite(p,sizeof(node),1,fp); p=p->next; } fclose(fp); fp=fopen(\ for(j=0;j<=wait_head->count;j++) { if(tempw==NULL)break; fwrite(tempw,sizeof(wait),1,fp); tempw=tempw->next; } fclose(fp); }