#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct book
{
int flag;
int number;
char name[20];
char writer[20];
char print[20];
float prince;
}book[200]
void newlib(struct book[i],int n)
{
int i;
FILE*fp;
if((fp=fopen("record.tex","wb"))==NULL)
{ printf("can not open fire\n");
exit(1)
{
printf("\n saving file\n");
fprintf(fp,"%d",n);
fprintf(fp,"\r\n");
for(i=0;i<n;i++);
{ fprintf(fp,"%d",number;"%s",name;"%s",writer;"%s",print;"%d",price);
fprintf(fp,"\r\n");
}
fclose(fp);
printf("*********save success*********\n");
}
}
}
void appendbook()
{
int n;
page_title("append a new book");
for(n=0;n<200;n++)
if(book[n].id==0) break;
printf("number:");
scanf("%d",&book[n].number);
printf("name:");
scanf("%s",&book[n].name);
printf("writer:");
scanf("%s",&book[n].writer);
printf("print:");
scanf("%s",&book[n].print);
printf("price");
scanf("%d",&book[n].price);
return confirm();
}
void delbook()
{
int n;
page_title("delete this book");
if((n=searchbook())!==1)
book[n].id=0;
printf("this book is deleted");
return_confirm();
}
void searchbook()
{
int n,i;
printf("please inputb book'number:");
scanf("%d",&i);
for(n=0;n<200;n++)
{
if (book[n].id==i)
{
printf("number:%d\n",book[n].number);
printf("name:%s\n",book[n].name);
return n;
}
}
}
void sortby price()
{int i,j,t;
FILE *fp;
if(fp=fopen=("book.txt","rb")=NULL)
{printf("cannot open the file.\n");
exit(0);
}
for(i=0;i<N;j++)
for(j=i+1;j<N;j++)
if(book[i].price<book[j].price)
{
t=book.price[i];
book[i]=book[j];
book[j]=t;
}
}
void sortby num()
{
int i,j,t;
FILE *fp;
if(fp=fopen=("book.txt","rb")=NULL)
{printf("cannot open the file.\n");
exit(0);
}
for(i=0;i<N;j++)
for(j=i+1;j<N;j++)
if(book[i].num<book[j].num)
{
t=book.num[i];
book[i]=book[j];
book[j]=t;
}
}