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

📄 search.cpp

📁 图书馆管理系统 包括界面、书籍管理、会员管理等内容
💻 CPP
字号:
/********************Search******************/
# include"liba.h"
void search()
{
     int i;
     window(1,1,80,2);
     textbackground(LIGHTGRAY);
     clrscr();
     textcolor(YELLOW);
     gotoxy(32,1);
     cprintf("Search");
     for(;1;)
     {
     window(1,2,80,25);
     textcolor(WHITE);
     textbackground(BLUE);
     clrscr();
     printf("\n\t\t\tWhat do you want to check by?");
     textcolor(YELLOW);
     gotoxy(16,3);cprintf("1.");
     textcolor(WHITE);
     cprintf("name");
     textcolor(YELLOW);
     gotoxy(16,4);
     cprintf("2.");
     textcolor(WHITE);
     cprintf("publisher");
     textcolor(YELLOW);
     gotoxy(16,5);
     cprintf("3.");
     textcolor(WHITE);
     cprintf("auther");
     textcolor(YELLOW);
     gotoxy(16,6);
     cprintf("4.");
     textcolor(WHITE);
     cprintf("type");
     textcolor(YELLOW);
     gotoxy(16,7);
     cprintf("5.");
     textcolor(WHITE);
     cprintf("back");
     textcolor(MAGENTA);
     gotoxy(16,8);
     cprintf("Please input your choice::  ");
     textcolor(WHITE);
     scanf("%d",&i);
     if(i==5)break;
     chkbook2(i);
   }
}
 void chkbook2(int i)
{

    struct book B;
  clrscr();
  FILE *fb;
  fb=fopen("E:\\cpp\\book.dat","r");
  int j;
  char str[20];

  switch(i)
  {
    case 1:
       j=0;
       rewind(fb);
       printf("\nPlease input the name::  ");
       fflush(stdin);
       gets(str);
       str[19]=' ';str[20]='\0';
       while(fread(&B,sizeof(B),1,fb)==1)
       {
         if(strcmp(B.bname,str)==1)
         {
                       printf("\n\t\t************* List Of All Books ****************   ");
                       printf("\n|----------|-------------------|--------------|-------------------|-------|");
                       printf("\n| Book Id  |    Book Name      |  Author Name |Publisher's Name   | Price |");
                       printf("\n|----------|-------------------|--------------|-------------------|-------|");
                       printf("\n|%4d3%d%3d|",B.b.bno,B.b.gno,B.b.no);
                       printf("%-19s|%-14s|%-19s| %4f  |",B.bname,B.author,B.pub,B.price);
                       j++;
         }
       }
       break;
    case 2:
       j=0;
       rewind(fb);
       printf("\nPlease input the publisher::");
       fflush(stdin);
       gets(str);
       str[19]=' ';str[20]='\0';
       while(fread(&B,sizeof(B),1,fb)==1)
       {
         if(strcmp(B.bname,str)==1)
         {
                       printf("\n\t\t************* List Of All Books ****************   ");
                       printf("\n|----------|-------------------|--------------|-------------------|-------|");
                       printf("\n| Book Id  |    Book Name      |  Author Name |Publisher's Name   | Price |");
                       printf("\n|----------|-------------------|--------------|-------------------|-------|");
                       printf("\n|%d%d%d  |",B.b.bno,B.b.gno,B.b.no);
                       printf("%-19s|%-14s|%-19s|%4f|",B.bname,B.author,B.pub,B.price);
                       j++;
         }
       }
       break;
     case 3:
       j=0;
       rewind(fb);
       printf("\nPlease input the author::  ");
       fflush(stdin);
       gets(str);
       str[14]=' ';str[15]='\0';
       while(fread(&B,sizeof(B),1,fb)==1)
       {
         if(strcmp(B.bname,str)==1)
         {
                             printf("\n\t\t************* List Of All Books ****************   ");
                             printf("\n|----------|-------------------|--------------|-------------------|-------|");
                             printf("\n| Book Id  |    Book Name      |  Author Name |Publisher's Name   | Price |");
                             printf("\n|----------|-------------------|--------------|-------------------|-------|");
                             printf("\n|%d%d%d  |",B.b.bno,B.b.gno,B.b.no);
                             printf("%-19s|%-14s|%-19s|%4f|",B.bname,B.author,B.pub,B.price);
                             j++;
         }
       }
       break;
      case 4:
       j=0;
       rewind(fb);
       printf("\nPlease input the type::  ");
       fflush(stdin);
       gets(str);
       str[19]=' ';str[20]='\0';
       while(fread(&B,sizeof(B),1,fb)==1)
       {
         if(strcmp(B.bname,str)==1)
         {
                             printf("\n\t\t************* List Of All Books ****************   ");
                             printf("\n|----------|-------------------|--------------|-------------------|-------|");
                             printf("\n| Book Id  |    Book Name      |  Author Name |Publisher's Name   | Price |");
                             printf("\n|----------|-------------------|--------------|-------------------|-------|");
                             printf("\n|%d%d%d  |",B.b.bno,B.b.gno,B.b.no);
                             printf("%-19s|%-14s|%-19s|%4f|",B.bname,B.author,B.pub,B.price);
                             j++;
         }
       }
       break;

  }
   fclose(fb);
  if(j==0)
   {
     textcolor(RED);
     cprintf("no such book exist!");
   }
   else
    {
     printf("\n|----------|-------------------|--------------|-------------------|-------|");
    }
   textcolor(RED);
   gotoxy(2,24);
   cprintf("press any key to return");
   getch();
}

⌨️ 快捷键说明

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