大一计算机上机题目及答案(西电专用) 联系客服

发布时间 : 星期四 文章大一计算机上机题目及答案(西电专用)更新完毕开始阅读

}

}

return select; //返回要操作的编号

int select_menu(){ //菜单挑选函数 int sel=menu(),a=0;

switch(sel){

case 1:printf_file();system(\

case 2:add_file();system(\ case 3:delet_file();system(\ case 4:borrow();system(\ };

books *read_file(){ //文件读取函数 FILE *np;

case 5:huan();system(\ case 6:a=1;break; } return a;

books *p,*q,*head,A; head=p=NULL;

if((np=fopen(\

printf(\

fscanf(np,\

r,A.state);

if(strcmp(\

\

fscanf(np,\

while(!feof(np)){

p=(books*)malloc(sizeof(books));

p->id=A.id;strcpy(p->name,A.name);strcpy(p->ISBN,A.ISBN);

p->price=A.price;strcpy(p->writer,A.writer);strcpy(p->state,A.state);

if(strcmp(\

\

{strcpy(p->stu.name,A.stu.name);strcpy(p->stu.id,A.stu.id);strcpy(p->stu.sex,A.stu.sex);}

fscanf(np,\

if(head==NULL) head=p; else q->next=p; q=p;

r,A.state);

if(strcmp(\

\

fscanf(np,\

}

}

q->next=NULL;fclose(np); return head;

void write_file(Linkbook head){ //文件重新写入函数

Linkbook p=head;FILE *np;

if((np=fopen(\

printf(\

while(p!=NULL){

fprintf(np,\price,p->writer,p->state);

if(strcmp(\

\

fprintf(np,\ }

void printf_file(){ //信息查询函数 Linkbook p=read_file();system(\ printf_title();

}

else fprintf(np,\

p=p->next;

fclose(np);

while(p!=NULL){ printf(\

%s)\\tISBN:%s\\t

价%.2f\\t%s\\t\

if(strcmp(\

\

printf(\ }

void delet_file(){ //人员删除函数 int i,n=1;

Linkbook head,p=read_file(),q=p;head=p; }

else printf(\ p=p->next;

printf_file();

printf(\请输入要删除的图书编号\\n\

while(p!=NULL){ if(i==p->id)

if(n==1) {head=p->next;break;} else break;

q=p;

p=p->next; ++n;

}