⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 complete.c

📁 简易的图书馆管理系统
💻 C
字号:
#include<stdio.h>

struct BOOK
{
char NA[10];
char WR[10];
char CB[10];
char NU[10];
};

void list()
{
clrscr();
printf("The Management of Libraries\n");
printf("***************************\n");
printf("1-Add Books\n");
printf("2-Search by name\n");
printf("3-Search by writer\n");
printf("4-Search by publisher\n");
printf("5-Search by number\n");
printf("6-About\n");
printf("7-Exit\n");
}

void judge(int a)
{
struct BOOK bok,bok0={"","",};
int b,c,d;
    if (a==1)
    {
     FILE *fp;
     fp=fopen("bok.dat","wb+");
     if(fp==NULL)
        {
         printf("file not open!");
         getch();
         return;
        }
     else
        {
        bok=bok0;
        printf ("Please input the name of the book\n");
        scanf ("%s",&bok.NA);
        printf ("Please input the writer of the book\n");
        scanf ("%s",&bok.WR);
        printf ("Please input the publisher of the book\n");
        scanf ("%s",&bok.CB);
        printf ("Please input the number of the book\n");
        scanf ("%s",&bok.NU);
        fwrite(&bok,sizeof(struct BOOK),1,fp);
        fclose(fp);
        }
    }
    if (a==2)
    {
    FILE *fp;
    struct BOOK bokk;
    fp=fopen("bok.dat","rb");
    if(fp==NULL)
        {
         printf("file not open!");
         getch();
         return;
        }
    printf("Please input the book's name\n");
    scanf ("%s",&bokk.NA);
    rewind(fp);
    fread(&bok,sizeof(struct BOOK),1,fp);
    if(strcmp(bokk.NA,bok.NA)==0)
        {
         printf("%s,%s,%s,%s",&bok.NA,&bok.WR,&bok.CB,&bok.NU);
        }
    else printf("No one");
    }
    if (a==3)
    {
    FILE *fp;
    struct BOOK bokk;
    fp=fopen("bok.dat","rb");
    if(fp==NULL)
        {
         printf("file not open!");
         getch();
         return;
        }
    printf("Please input the writer's name\n");
    scanf ("%s",&bokk.WR);
    rewind(fp);
    fread(&bok,sizeof(struct BOOK),1,fp);
    if(strcmp(bokk.WR,bok.WR)==0)
        {
         printf("%s,%s,%s,%s",&bok.NA,&bok.WR,&bok.CB,&bok.NU);
        }
    else printf("No one");
    }
    if (a==4)
    {
    FILE *fp;
    struct BOOK bokk;
    fp=fopen("bok.dat","rb");
    if(fp==NULL)
        {
         printf("file not open!");
         getch();
         return;
        }
    printf("Please input the publisher\n");
    scanf ("%s",&bokk.CB);
    rewind(fp);
    fread(&bok,sizeof(struct BOOK),1,fp);
    if(strcmp(bokk.CB,bok.CB)==0)
        {
         printf("%s,%s,%s,%s",&bok.NA,&bok.WR,&bok.CB,&bok.NU);
        }
    else printf("No one");
    }
    if (a==5)
    {
    FILE *fp;
    struct BOOK bokk;
    fp=fopen("bok.dat","rb");
    if(fp==NULL)
        {
         printf("file not open!");
         getch();
         return;
        }
    printf("Please input the number\n");
    scanf ("%s",&bokk.NU);
    rewind(fp);
    fread(&bok,sizeof(struct BOOK),1,fp);
    if(strcmp(bokk.NU,bok.NU)==0)
        {
         printf("%s,%s,%s,%s",&bok.NA,&bok.WR,&bok.CB,&bok.NU);
        }
    else printf("No one");
    }
    if (a==6)
    {
    printf("\n");
    printf("****************************\n");
    printf("Maker:\n");
    printf("      Zhangyu     06021207\n");
    printf("      Chenhao     06021216\n");
    printf("      Zhangzhibao 06021234\n");
    }
    if (a==7)
    exit();
}

main()
{
int a;
loop:list();
scanf ("%d",&a);
judge(a);
getch();
goto loop;
getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -