#include<stdio.h>
#include<string.h>
#include<conio.h>
#define N 6
struct library{int NUM;char book[100];float money;char name[50];char sign[100];
};
void lookup(struct library *L)
{ int n,i;do{printf("输入想查找书的编号(按0退出查看功能):");scanf("%d",&n); for(i=0;i<10;i++){if(n == (L+i)->NUM) { printf(" 编号:%d \t书名:%s \t价钱:%.2f \t借阅人:%s \t状态:%s\n", (L+i)->NUM,(L+i)->book,(L+i)->money,(L+i)->name,(L+i)->sign);}}}while(n!=0); printf("借书(1)or离开(0)\n");scanf("%d",&n);if(n==0)printf("算了,走了\n");else if(n==1){ int j,inp; char c[N];printf("--load--\n");printf("\n");printf("请输入你想借阅的书编号:\n");scanf("%d",&inp); getchar();for(j=0;j<10;j++){ if(inp == (L+j)->NUM) {if(strlen((L+j)->sign)==8) { printf("输入姓名标记借出\n");gets(c);printf("\n");printf("|->回车键确认借出<-|\n");getch();strcpy((L+j)->name,c); strcpy((L+j)->sign,"done"); printf("Success!\n");printf(" 编号:%d \t书名:%s \t价钱:%.2f \t借阅人:%s \t状态:%s\n",(L+j)->NUM,(L+j)->book,(L+j)->money,(L+j)->name,(L+j)->sign);}elseprintf("此书也被借出\n");}}}
}
int main()
{struct library LIB[]={ {1,"《Pride and Prejudice》",42.20,"yangwz","done"}, {2,"《Ulysses》",36.10,"none","Loanable"},{3,"《Moby-Dick》",25.00,"yangyl","done"},{4,"《To Kill A Mockingbird》",31.21,"none","Loanable"},{5,"《The Big Sleep》",19.99,"none","Loanable"},{6,"《Lord of the flies》",29.99,"none","Loanable"},{7,"《Jane Eyre》",60.20,"none","Loanable"},{8,"《FLIPPED》",20.6,"yangzw","done"},{9,"《Tuesdays with Morrie》",21.4,"none","Loanable"},{10,"《Sweetbitter》",44.44,"yangwwz","done"},};lookup(LIB);return 0;
}