欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C語言實(shí)現(xiàn)簡單的圖書管理系統(tǒng)

 更新時(shí)間:2021年03月10日 08:26:34   作者:Sriven  
這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)簡單的圖書管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C語言實(shí)現(xiàn)簡單圖書管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

代碼:

/*
 課程設(shè)計(jì)項(xiàng)目名稱:圖書查詢系統(tǒng)
 作者:施瑞文
 時(shí)間:2018.3.4 
*/ 
#include<stdio.h>
#include<string.h>
#include<windows.h>
#include<conio.h>
#include<stdlib.h>
#define N sizeof(struct BOOK)
 
struct BOOK    //圖書信息 
{
 char number[10];  //登錄號(hào) 
 char name[10];   //書名 
 char author[10];  //作者名 
 char type[10];   //類型 
 char publish[10]; //出版單位 
 char time[8];    //出版時(shí)間 
 float price;    //價(jià)格 
 int num;     //數(shù)量 
 int x;
 struct BOOK *next;  //指針域 
};
typedef struct BOOK Book;
typedef Book *book; 
 
void HideCursor();  //隱藏光標(biāo)
void toxy(int x, int y);  //將光標(biāo)移動(dòng)到X,Y坐標(biāo)處
void color(short x);   //設(shè)置顏色
void over();       //退出 
void menu();      //菜單 
void input_book();   //圖書入庫 
void save_book(book p);//將圖書信息存入文件 
void find_book();   //查詢 
void print_book();  //圖書總覽 
void del_book();   //刪除圖書 
void amend_book();  //修改信息 
book ss();
void find_name_book(); //按書名查詢 
void find_author_book(); //按作者查詢 
void find_number_book(); //按登錄號(hào)查詢
void find_publish_book(); //按出版社查詢 
void fuzzy_search();   //模糊查找 
 
void HideCursor()   //隱藏光標(biāo)
{
 CONSOLE_CURSOR_INFO cursor_info = {1, 0}; 
 SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
 
void color(short x)
{
 if(x>=0&&x<=15)
 {
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
 }
 else
 {
 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
 }
} 
 
void toxy(int x, int y)   //將光標(biāo)移動(dòng)到X,Y坐標(biāo)處
{
COORD pos = { x , y };
HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(Out, pos); 
}
 
void menu()  //菜單 
{
 do
 {
 system("cls"); //清屏 
 HideCursor(); //隱藏光標(biāo) 
 color(15);  //設(shè)置一個(gè)好看的顏色 
 char t;
 toxy(50,5);//將光標(biāo)移動(dòng)到(50,5)坐標(biāo)處
 printf(" 圖書查詢管理系統(tǒng)");
 toxy(48,8);
 printf("|   1.圖書入庫   |");
 toxy(48,10);
 printf("|   2.修改信息   |");
 toxy(48,12);
 printf("|   3.刪除信息   |");
 toxy(48,14);
 printf("|   4.圖書查詢   |");
 toxy(48,16);
 printf("|   5.圖書總覽   |");
 toxy(48,18);
 printf("|   6.退出軟件   |");
 t=getch();  //不回顯函數(shù) 
 switch(t)
 {
  case '1':input_book();break;
  case '2':amend_book();break;
  case '3':del_book();break;
  case '4':find_book();break;
  case '5':print_book();break; 
  case '6':over();break;
  default :break;
 }
 }while(1);
} 
 
book ss()   //將文件中的內(nèi)容讀出到鏈表中,返回值為表頭地址 
{
 FILE *fp;    //文件指針 
 int n=0;
 book head=NULL;
 book p2,p,pr=NULL;
 fp=fopen("mybook","ab+");   //以只讀的方式打開文件 
 if(fp==NULL)
 {
 printf("cannot open file\n");
 }
 while(!feof(fp))    //判斷文件位置標(biāo)志是否移動(dòng)到文件末尾 
 {
  n++;
   p=(book)malloc(N); //向內(nèi)存申請(qǐng)一段空間 
  fread(p,N,1,fp);   //將fp所指向的文件中的內(nèi)容賦給p 
  if(n==1)
  {
    head=p;
    p2=p;
   }
   else       //創(chuàng)建鏈表 
   {
   pr=p2;
   p2->next=p;
   p2=p;
 }
  }
  if(pr!=NULL)
    pr->next=NULL;
  else
    head=NULL;
  fclose(fp);  //關(guān)閉文件 
  return head;  //返回頭指針 
}
 
void input_book()  //圖書錄入 
{
 do
 {
 system("cls");
 color(10);
 char t;
 book p;
 p=(book)malloc(N);   //申請(qǐng)空間 
 //輸入圖書信息
 toxy(48,8);
 printf("請(qǐng)輸入圖書登錄號(hào)(小于10位數(shù)):");  
 scanf("%s",p->number);getchar();
 toxy(48,10);
 printf("請(qǐng)輸入書名(小于10位數(shù)):");
 scanf("%s",p->name);getchar();
 toxy(48,12);
 printf("請(qǐng)輸入作者名(小于10位數(shù)):");
 scanf("%s",p->author);getchar();
 toxy(48,14);
 printf("請(qǐng)輸入圖書類別(小于10位數(shù)):");
 scanf("%s",p->type);getchar();
 toxy(48,16);
 printf("請(qǐng)輸入圖書出版單位(小于10位數(shù)):");
 scanf("%s",p->publish);getchar();
 toxy(48,18);
 printf("請(qǐng)輸入圖書出版時(shí)間(小于8位數(shù)):");
 scanf("%s",p->time);getchar();
 toxy(48,20);
 printf("請(qǐng)輸入圖書價(jià)格:");
 scanf("%f",&p->price);getchar();
 toxy(48,22);
 printf("請(qǐng)輸入圖書數(shù)量:");
 scanf("%d",&p->num);
 save_book(p);
 toxy(48,24);
 printf("正在保存....");
 Sleep(500);  //暫停0.5秒 
 system("cls");
 toxy(46,8);
 printf("-------------------------");
 toxy(46,9);
 printf("|            |");
 toxy(46,10);
 printf("| 保存成功!是否繼續(xù)? |");
 toxy(46,12);
 printf("| 1.是       2.否 |");
 toxy(46,13);
 printf("|            |");
 toxy(46,14);
 printf("-------------------------");
 while(1)  //利用死循環(huán)可有效防止其他按鍵干擾 
 {
  t=getch();
  if(t=='1')
  {
  break;
  } 
  else if(t=='2')
  {
   menu();
  }
 }
 }while(1);
 
} 
 
void amend_book()  //修改圖書信息 
{
 do
 {
 system("cls");
 color(10);
 book head,p;
 int i=11,j=0,x;
 char ch,t;
 FILE *fp;  //文件指針 
 char _name[10];
 char number[10];  //登錄號(hào) 
 char name[10];   //書名 
 char author[10];  //作者名 
 char type[10];   //類型 
 char publish[10]; //出版單位 
 char time[8];    //出版時(shí)間 
 float price;    //價(jià)格 
 int num;     //數(shù)量 
 head=ss();
 p=head;
 toxy(48,10);
 printf("請(qǐng)輸入你要修改的圖書的書名:");
 gets(_name); 
 while(p!=NULL)  //初始化p->x為0 
 {
  p->x=0;
  p=p->next;
 }
 p=head;  //讓p重新指向表頭 
 toxy(20,5);
 printf("***********************************************圖書信息******************************************************");
 toxy(20,8);
 printf("-------------------------------------------------------------------------------------------------------------");
 toxy(20,9);
 printf("登錄號(hào)    書名    作者名     圖書類別     出版單位     出版時(shí)間     價(jià)格    數(shù)量");
 toxy(20,10);
 printf("-------------------------------------------------------------------------------------------------------------");
 while(p!=NULL)
 {
  if(p!=NULL&&strcmp(p->name,_name)==0)
  {
  toxy(20,i);
  j++;
  printf("%d:%s%14s%14s%14s  %14s  %18s     %.2f%12d\n",j,p->number,p->name,p->author,p->type,p->publish,p->time,p->price,p->num);
  p->x=j;  //給符合查詢標(biāo)準(zhǔn)的結(jié)點(diǎn)標(biāo)號(hào) 
  i++;
  }
  p=p->next;
 }
 if(j==0)          //如果j=0,即沒有進(jìn)入前面的搜索循環(huán),也就是沒有找到相應(yīng)的信息 
 { 
  toxy(50,i);
  printf("沒有找到相應(yīng)的信息!(按0返回,按1重新搜索)");
  while(1)        //死循環(huán)是為了防止除0和1的其他按鍵干擾 
  {
  ch=getch();
  if(ch=='0')
  {
   menu();break;
  }
  else if(ch=='1')
  {
   break;
  }
  }
  if(ch=='1')   //如果輸入的ch等于1,則結(jié)束本次循環(huán) 
   continue;
 }
 while(1)
 {
  toxy(45,i);
  printf("請(qǐng)輸入您要修改的圖書的編號(hào):");
  scanf("%d",&x);getchar();
  if(x>j||x==0)   
  {
  toxy(45,++i);
  printf("輸入錯(cuò)誤,請(qǐng)重新輸入!");
  Sleep(500);
  }
  else
  {
  break;
  }
 }
 p=head;   //讓p重新指向表頭 
 while(p!=NULL&&p->x!=x)  //遍歷鏈表查詢符合條件的結(jié)點(diǎn) 
 {
  p=p->next;
 }
 if(p)  //如果p不為空 
 {
  system("cls");
  //輸入要修改的信息 
  toxy(48,8);
  printf("請(qǐng)輸入圖書登錄號(hào)(小于10位數(shù)):");
  scanf("%s",number);getchar();strcpy(p->number,number);
  toxy(48,10);
  printf("請(qǐng)輸入書名(小于10位數(shù)):");
  scanf("%s",name);getchar();strcpy(p->name,name);
  toxy(48,12);
  printf("請(qǐng)輸入作者名(小于10位數(shù)):");
  scanf("%s",author);getchar();strcpy(p->author,author);
  toxy(48,14);
  printf("請(qǐng)輸入圖書類別(小于10位數(shù)):");
  scanf("%s",type);getchar();strcpy(p->type,type);
  toxy(48,16);
  printf("請(qǐng)輸入圖書出版單位(小于10位數(shù)):");
  scanf("%s",publish);getchar();strcpy(p->publish,publish);
  toxy(48,18);
  printf("請(qǐng)輸入圖書出版時(shí)間(小于8位數(shù)):");
  scanf("%s",time);getchar();strcpy(p->time,time);
  toxy(48,20);
  printf("請(qǐng)輸入圖書價(jià)格:");
  scanf("%f",&price);getchar();p->price=price;
  toxy(48,22);
  printf("請(qǐng)輸入圖書數(shù)量:");
  scanf("%d",&num);getchar();p->num=num;
 }
 color(7);
 toxy(46,8);
 printf("-------------------------");
 toxy(46,9);
 printf("|            |");
 toxy(46,10);
 printf("|   是否確認(rèn)修改?  |");
 toxy(46,12);
 printf("| 1.是       2.否 |");
 toxy(46,13);
 printf("|            |");
 toxy(46,14);
 printf("-------------------------");
 while(1)  //利用死循環(huán)防止其他按鍵干擾 
 {
  t=getch();
  if(t=='1')
  {
  break;
  } 
  else if(t=='2')
  {
  menu();
  }
 }
 system("cls");
 toxy(46,10);
 printf("正在修改,請(qǐng)稍后....");
 fp=fopen("mybook","wb");  //以只寫的方式打開名為mybook的二進(jìn)制文件,打開的同時(shí)清空文件中的內(nèi)容 
 if(fp==NULL)
 {
  printf("cannot open file"); 
 }
 if(fwrite(head,N,1,fp)!=1)  //將head寫入fp所指向的文件中 
 {
  printf("write error!"); 
 }
 fclose(fp);  //關(guān)閉文件 
 if(head!=NULL)  //如果head不為空 
 {
  p=head->next;   //讓p指向第二個(gè)結(jié)點(diǎn) 
  fp=fopen("mybook","ab");  //以追加的方式打開文件 
  if(fp==NULL)
  {
  printf("cannot open file");
  }
  while(p!=NULL)
  {
  if(fwrite(p,N,1,fp)!=1)//將p寫入fp所指向的文件中
  {
   printf("write error!");
  }
  p=p->next;
  }
  fclose(fp); //關(guān)閉文件 
 }
 Sleep(500);  //暫停0.5秒 
 system("cls");
 toxy(46,10);
 printf("修改成功!即將自動(dòng)返回主菜單....");
 Sleep(500);
 break;
 }while(1);
}
 
void del_book()  //刪除信息 
{
 do
 {
 system("cls");
 color(9);
 FILE *fp;
 book head,p,pre=NULL; 
 int j=0,x,i=11;
 char name[10];
 char t,c,ch;
 head=ss();  //調(diào)用函數(shù),返回表頭地址 
 toxy(48,10);
 printf("請(qǐng)輸入你要?jiǎng)h除的圖書的書名:");
 scanf("%s",name);
 p=head;
 while(p!=NULL)
 {
  p->x=0;
  p=p->next;
 }
 p=head;
 toxy(20,5);
 printf("***********************************************圖書信息******************************************************");
 toxy(20,8);
 printf("-------------------------------------------------------------------------------------------------------------");
 toxy(20,9);
 printf("登錄號(hào)    書名    作者名     圖書類別     出版單位     出版時(shí)間     價(jià)格    數(shù)量");
 toxy(20,10);
 printf("-------------------------------------------------------------------------------------------------------------");
 while(p!=NULL)
 {
  if(p!=NULL&&strcmp(p->name,name)==0)
  {
  toxy(20,i);
  j++;
  printf("%d:%s%14s%14s%14s  %14s  %18s     %.2f%12d\n",j,p->number,p->name,p->author,p->type,p->publish,p->time,p->price,p->num);
  p->x=j;
  i++;
  }
  p=p->next;
 }
 if(j==0)          //如果j=0,即沒有進(jìn)入前面的搜索循環(huán),也就是沒有找到相應(yīng)的信息 
 { 
  toxy(50,i);
  printf("沒有找到相應(yīng)的信息!(按0返回,按1重新搜索)");
  while(1)        //死循環(huán)是為了防止除0和1的其他按鍵干擾 
  {
  ch=getch();
  if(ch=='0')
  {
   menu();break;
  }
  else if(ch=='1')
  {
   break;
  }
  }
  if(ch=='1')   //如果輸入的ch等于1,則結(jié)束本次循環(huán) 
   continue;
 }
 while(1)
 {
  toxy(45,i);
  printf("請(qǐng)輸入您要?jiǎng)h除的圖書的編號(hào):");
  scanf("%d",&x);getchar();
  if(x>j||x==0)
  {
  toxy(45,++i);
  printf("輸入錯(cuò)誤,請(qǐng)重新輸入!");
  Sleep(500);
  }
  else
  {
  break;
  }
 }
 color(7);
 toxy(46,8);
 printf("-------------------------");
 toxy(46,9);
 printf("|            |");
 toxy(46,10);
 printf("|   是否確認(rèn)刪除?  |");
 toxy(46,12);
 printf("| 1.是       2.否 |");
 toxy(46,13);
 printf("|            |");
 toxy(46,14);
 printf("-------------------------");
 while(1)
 {
  t=getch();
  if(t=='1')
  {
  break;
  } 
  else if(t=='2')
  {
  menu();
  }
 }
 p=head;
 while(p!=NULL&&p->x!=x)
 {
  pre=p;
  p=p->next;
 }
 if(p!=NULL)
 {
  if(pre==NULL)
  {
  head=head->next;
  }
  else
  {
  pre->next=p->next;
  }
 }
 free(p);
 fp=fopen("mybook","wb");
 if(fp==NULL)
 {
  printf("cannot open file"); 
 }
 if(fwrite(head,N,1,fp)!=1)
 {
  printf("write error!"); 
 }
 fclose(fp);
 if(head!=NULL)
 {
  p=head->next;
  fp=fopen("mybook","ab");
  if(fp==NULL)
  {
  printf("cannot open file");
  }
  while(p!=NULL)
  {
  if(fwrite(p,N,1,fp)!=1)
  {
   printf("write error!");
  }
  p=p->next;
  }
  fclose(fp);
 }
 system("cls");
 toxy(46,10);
 printf("正在刪除,請(qǐng)稍后....");
 Sleep(500);
 system("cls");
 toxy(46,8);
 printf("-------------------------");
 toxy(46,9);
 printf("|            |");
 toxy(46,10);
 printf("| 刪除成功,是否繼續(xù)? |");
 toxy(46,12);
 printf("| 1.是       2.否 |");
 toxy(46,13);
 printf("|            |");
 toxy(46,14);
 printf("-------------------------");
 while(1)
 {
  c=getch();
  if(c=='1')
  {
  break;
  }
  else if(c=='2')
  {
  menu();
  }
 }
 }while(1);
}
 
void print_book()  //圖書總覽 
{
 system("cls");
 color(6);
 book head,p;
 int i=11;
 int sum=0;
 head=ss();
 toxy(20,5);
 printf("***********************************************圖書總覽******************************************************");
 toxy(20,8);
 printf("-------------------------------------------------------------------------------------------------------------");
 toxy(20,9);
 printf("登錄號(hào)    書名    作者名     圖書類別     出版單位     出版時(shí)間     價(jià)格    數(shù)量");
 toxy(20,10);
 printf("-------------------------------------------------------------------------------------------------------------");
 if(head==NULL)
 {
 toxy(45,11);
 printf("書庫暫時(shí)沒有書哦~趕快去添加幾本吧^_^(按任意鍵返回)");
 getch();
 menu();
 }
 p=head;
 while(p!=NULL)
 {
 toxy(20,i);
 printf("%s%14s%14s%14s  %14s  %18s     %.2f%12d\n",p->number,p->name,p->author,p->type,p->publish,p->time,p->price,p->num);
 i++;
 sum+=p->num;//計(jì)算圖書總量 
 p=p->next;
 }
 toxy(48,7);
 printf("圖書總量為:%d",sum);
 toxy(45,i);
 printf("按任意鍵返回");
 getch();//不回顯函數(shù) 
}
 
void find_book() //查詢圖書 
{
 do
 {
 system("cls"); //清屏 
 color(8);
 char t;
 toxy(50,5);
 printf(" 圖書查詢");
 toxy(48,8);
 printf("|   1.書名 查詢   |");
 toxy(48,10);
 printf("|   2.作者 查詢   |");
 toxy(48,12);
 printf("|   3.登錄號(hào)查詢   |");
 toxy(48,14);
 printf("|   4.出版社查詢   |");
 toxy(48,16);
 printf("|   5.模糊 查詢   |");
 toxy(50,18);
 printf("按0返回主菜單");
 t=getch();
 switch(t)
 {
  case '0':menu();break;
  case '1':find_name_book();break;
  case '2':find_author_book();break;
  case '3':find_number_book();break;
  case '4':find_publish_book();break;
  case '5':fuzzy_search();break;
  default :break;
  } 
 }while(1);
}
 
void find_name_book() //按名字查詢 
{
 system("cls");
 color(8);
 book head,p;
 int i=11;
 head=ss();
 char name[10];
 toxy(48,8);
 printf("請(qǐng)輸入您要查詢圖書的書名:");
 gets(name);
 toxy(48,10);
 printf("正在查詢....");
 Sleep(500);
 p=head;
 toxy(20,5);
 printf("***********************************************圖書總覽******************************************************");
 toxy(20,8);
 printf("-------------------------------------------------------------------------------------------------------------");
 toxy(20,9);
 printf("登錄號(hào)    書名    作者名     圖書類別     出版單位     出版時(shí)間     價(jià)格    數(shù)量");
 toxy(20,10);
 printf("-------------------------------------------------------------------------------------------------------------");
 while(p!=NULL)
 {
 if(p!=NULL&&strcmp(p->name,name)==0)
 {
  toxy(20,i);
  printf("%s%14s%14s%14s  %14s  %18s     %.2f%12d\n",p->number,p->name,p->author,p->type,p->publish,p->time,p->price,p->num);
  i++;
 }
 p=p->next;
 }
 toxy(45,i);
 printf("按任意鍵返回!");
 getch();
 find_book();
}
 
void find_author_book()  //按作者名查詢 
{
 system("cls");
 color(8);
 book head,p;
 int i=11;
 head=ss();
 char author[10];
 toxy(48,8);
 printf("請(qǐng)輸入您要查詢圖書的作者名:");
 gets(author);
 toxy(48,10);
 printf("正在查詢....");
 Sleep(500);
 p=head;
 toxy(20,5);
 printf("***********************************************圖書總覽******************************************************");
 toxy(20,8);
 printf("-------------------------------------------------------------------------------------------------------------");
 toxy(20,9);
 printf("登錄號(hào)    書名    作者名     圖書類別     出版單位     出版時(shí)間     價(jià)格    數(shù)量");
 toxy(20,10);
 printf("-------------------------------------------------------------------------------------------------------------");
 while(p!=NULL)
 {
 if(p!=NULL&&strcmp(p->author,author)==0)
 {
  toxy(20,i);
  printf("%s%14s%14s%14s  %14s  %18s     %.2f%12d\n",p->number,p->name,p->author,p->type,p->publish,p->time,p->price,p->num);
  i++;
 }
 p=p->next;
 }
 toxy(45,i);
 printf("按任意鍵返回!");
 getch();
 find_book();
}
 
void find_number_book()  //按圖書編號(hào)查詢 
{
 system("cls");
 color(8);
 book head,p;
 int i=11;
 head=ss();
 char number[10];
 toxy(48,8);
 printf("請(qǐng)輸入您要查詢圖書的登錄號(hào):");
 gets(number);
 toxy(48,10);
 printf("正在查詢....");
 Sleep(500);
 p=head;
 toxy(20,5);
 printf("***********************************************圖書總覽******************************************************");
 toxy(20,8);
 printf("-------------------------------------------------------------------------------------------------------------");
 toxy(20,9);
 printf("登錄號(hào)    書名    作者名     圖書類別     出版單位     出版時(shí)間     價(jià)格    數(shù)量");
 toxy(20,10);
 printf("-------------------------------------------------------------------------------------------------------------");
 while(p!=NULL)
 {
 if(p!=NULL&&strcmp(p->number,number)==0)
 {
  toxy(20,i);
  printf("%s%14s%14s%14s  %14s  %18s     %.2f%12d\n",p->number,p->name,p->author,p->type,p->publish,p->time,p->price,p->num);
  i++;
 }
 p=p->next;
 }
 toxy(45,i);
 printf("按任意鍵返回!");
 getch();
 find_book();
}
 
void find_publish_book()  //按出版商查詢 
{
 system("cls");
 color(8);
 book head,p;
 int i=11;
 head=ss();
 char publish[10];
 toxy(48,8);
 printf("請(qǐng)輸入您要查詢圖書的出版社:");
 gets(publish);
 toxy(48,10);
 printf("正在查詢....");
 Sleep(500);
 p=head;
 toxy(20,5);
 printf("***********************************************圖書總覽******************************************************");
 toxy(20,8);
 printf("-------------------------------------------------------------------------------------------------------------");
 toxy(20,9);
 printf("登錄號(hào)    書名    作者名     圖書類別     出版單位     出版時(shí)間     價(jià)格    數(shù)量");
 toxy(20,10);
 printf("-------------------------------------------------------------------------------------------------------------");
 while(p!=NULL)
 {
 if(p!=NULL&&strcmp(p->publish,publish)==0)
 {
  toxy(20,i);
  printf("%s%14s%14s%14s  %14s  %18s     %.2f%12d\n",p->number,p->name,p->author,p->type,p->publish,p->time,p->price,p->num);
  i++;
 }
 p=p->next;
 }
 toxy(45,i);
 printf("按任意鍵返回!");
 getch();
 find_book();
}
 
void fuzzy_search()  //模糊查詢 
{
 system("cls");
 color(8);
 book head,p;
 int i=11;
 head=ss();
 char information[10];
 toxy(48,8);
 printf("請(qǐng)輸入您要查詢圖書的信息:");
 gets(information);
 toxy(48,10);
 printf("正在查詢....");
 Sleep(500);
 p=head;
 toxy(20,5);
 printf("***********************************************圖書總覽******************************************************");
 toxy(20,8);
 printf("-------------------------------------------------------------------------------------------------------------");
 toxy(20,9);
 printf("登錄號(hào)    書名    作者名     圖書類別     出版單位     出版時(shí)間     價(jià)格    數(shù)量");
 toxy(20,10);
 printf("-------------------------------------------------------------------------------------------------------------");
 while(p!=NULL)
 {
 if(p!=NULL&&(strcmp(p->name,information)==0||strcmp(p->author,information)==0||strcmp(p->number,information)==0||strcmp(p->publish,information)==0))
 {
  toxy(20,i);
  printf("%s%14s%14s%14s  %14s  %18s     %.2f%12d\n",p->number,p->name,p->author,p->type,p->publish,p->time,p->price,p->num);
  i++;
 }
 p=p->next;
 }
 toxy(45,i);
 printf("按任意鍵返回!");
 getch();
 find_book();
}
 
void save_book(book p)  //將p中內(nèi)容寫入文件 
{
 FILE *fp;  //文件指針 
 fp=fopen("mybook","ab");  //以追加的方式打開名字為mybook的二進(jìn)制文件 
 if(fp==NULL)
 {
 printf("cannot open file");
 }
 if(fwrite(p,N,1,fp)!=1)  //將p所指向的一段大小為N的內(nèi)容存入fp所指向的文件中 
 {
 printf("write error");
 }
 fclose(fp);  //關(guān)閉文件 
 } 
 
void over()    //退出軟件 
{
 char t;
 toxy(48,11);
 printf("-----------------------");
 toxy(48,12);
 printf("|  您確定要退出嗎? |");
 toxy(48,14);
 printf("| 1.確定   2.取消  |");
 toxy(48,15);
 printf("-----------------------");
 while(1)
 {
 t=getch();     //輸入t
 switch(t)
 {
  case '1':
  system("cls");
   color(6);
  toxy(48,10);
  printf("正在安全退出....");
  Sleep(1000);   //暫停1秒 
  system("cls");
  color(8);
  toxy(48,10);
  printf("已安全退出軟件");
  toxy(48,12);
  printf("謝謝使用!");
  toxy(48,14);
  printf("by-by^_^");
  exit(0); break; //終止程序 
  case '2':
  menu(); break;  //調(diào)用函數(shù),進(jìn)入菜單 
  default :break;
 }
 }
} 
 
main()  //簡潔明了的主函數(shù) 
{
 menu();//菜單 
}

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C語言軟件spi虛擬總線中間層設(shè)計(jì)詳解

    C語言軟件spi虛擬總線中間層設(shè)計(jì)詳解

    這篇文章主要為大家介紹了C語言軟件spi虛擬總線中間層設(shè)計(jì)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-01-01
  • C語言中((type *)0) 和(type *0)區(qū)別小結(jié)

    C語言中((type *)0) 和(type *0)區(qū)別小結(jié)

    ((type *)0)?和?(type *0)?在 C 和 C++ 中有不同的含義和用途,本文主要介紹了C語言中((type *)0) 和(type *0)區(qū)別,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-08-08
  • Qt編寫秒表功能

    Qt編寫秒表功能

    這篇文章主要為大家詳細(xì)介紹了Qt編寫秒表功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • wxWidgets實(shí)現(xiàn)圖片和文件按鈕

    wxWidgets實(shí)現(xiàn)圖片和文件按鈕

    這篇文章主要為大家詳細(xì)介紹了wxWidgets實(shí)現(xiàn)圖片和文件按鈕,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-02-02
  • 詳解C++文件讀寫操作

    詳解C++文件讀寫操作

    這篇文章主要為大家詳細(xì)介紹了C++文件讀寫操作,感興趣的小伙伴們可以參考一下
    2016-03-03
  • C++面試八股文之智能指針詳解

    C++面試八股文之智能指針詳解

    智能指針是C++11引入的類模板,用于管理資源,行為類似于指針,但不需要手動(dòng)申請(qǐng)、釋放資源,本文主要為大家介紹了它的相關(guān)知識(shí),需要的可以參考一下
    2023-06-06
  • C++ OpenCV實(shí)現(xiàn)圖像修復(fù)功能

    C++ OpenCV實(shí)現(xiàn)圖像修復(fù)功能

    這篇文章主要介紹了通過C++ OpenCV中提供的inpaint API實(shí)現(xiàn)對(duì)有瑕疵的圖像進(jìn)行修復(fù),文中的方法講解詳細(xì),感興趣的同學(xué)可以跟隨小編一起學(xué)習(xí)一下
    2022-01-01
  • C語言代碼實(shí)現(xiàn)三子棋游戲

    C語言代碼實(shí)現(xiàn)三子棋游戲

    這篇文章主要為大家詳細(xì)介紹了C語言代碼實(shí)現(xiàn)三子棋游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-11-11
  • C++實(shí)現(xiàn)騎士走棋盤算法

    C++實(shí)現(xiàn)騎士走棋盤算法

    這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)騎士走棋盤算法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-07-07
  • C++第三方日志庫log4cplus的安裝與使用配置教程

    C++第三方日志庫log4cplus的安裝與使用配置教程

    log4cplus是C++編寫的開源的日志系統(tǒng),log4cplus具有線程安全、靈活、以及多粒度控制的特點(diǎn),本文給大家介紹C++第三方日志庫log4cplus的安裝與使用教程,感興趣的朋友一起看看吧
    2022-02-02

最新評(píng)論