#include <stdio.

h>
#include <stdlib.h>
typedef struct book
{
char name[50];
struct book *next;
}BOOK_NODE;
typedef struct header
{
BOOK_NODE*front;
int counter;
BOOK_NODE*rear;
}META_HEADER;
META_HEADER* create(void)
{
META_HEADER* head;
head=(META_HEADER*)malloc(sizeof(META_HEADER));
if(head)
{
head->front=NULL;
head->rear=NULL;
head->counter=0;
}
return head;
}
void enqueue(META_HEADER* head,FILE* f)
{
BOOK_NODE* p;
p=(BOOK_NODE*)malloc(sizeof(BOOK_NODE));
int j;
for(j=0;j<50;j++)
{
fscanf(f,"%c",&(p->name[j]));//!
if(p->name[j]=='\n')
{
p->name[j]='0';
break;
}
}
p->next=NULL;
if(head->counter==0)
head->front=p;
else
head->rear->next=p;
(head->counter)++;
head->rear=p;
}
int main()
{
META_HEADER*list[10];
FILE*in;
in=fopen("input.txt","r");
FILE*out;
out=fopen("output.txt","w");
int n,i,flag;
for(i=0;i<10;i++)

} else if(n==9) { enqueue(list[9].in). } else if(n==6) { enqueue(list[6].in). for(i=0.in)."%d ".i++) { b=list[i]->front. } else if(n==4) { enqueue(list[4]. } else if(n==8) { enqueue(list[8]."error").in). if(flag==-1) break. if(b!=NULL) { . } else if(n==5) { enqueue(list[5].in).in). } else if(n==3) { enqueue(list[3].in).i<10. } BOOK_NODE* b. } else if(n==2) { enqueue(list[2]. int j.{ list[i]=create(). } else fprintf(out.in). } else if(n==7) { enqueue(list[7]. } else if(n==1) { enqueue(list[1]. } while(1) { flag=fscanf(in.in).&n). if(n==0) { enqueue(list[0].in).

fprintf(out.b->name[j])."%c". do { for(j=0."floor%d:". if(b!=NULL) fprintf(out.fprintf(out.i). } } fclose(in).//! } b=b->next. ").j<50."."\n").j++) { if(b->name[j]=='0') break. } . return 0. fclose(out). }while(b!=NULL). fprintf(out.

Sign up to vote on this title
UsefulNot useful