首页 > > 详细

辅导C/C++ 图书信息管理系统程序、辅导Java语言、SQL语言调试、辅导asp、Python编程讲解

#include
#include
#include
#include
#include"windows.h"
#define M 50
struct date
{ int year;
int month;
int day;
};
struct library
{
int book_num;
char book_name[40];
char author_name[10];
float book_price;
char publisher[40];
struct date publish_time;
char book_state[2];
char reader_name[10];
int reader_num;
};
int input(struct library book[]);
int add(struct library book[],int n);
void list(struct library book[],int n);
void search_num(struct library book[],int n);
void search_name(struct library book[],int n);
int Delete(struct library book[],int n);
void sort(struct library book[],int n);
void count(struct library book[],int n);
void unborrow(struct library book[],int n);
void saverecord(struct library book[],int n);
int loadrecord(struct library book[]);
int menu();
void main()
{
struct library b[M];
int length;
while(1)
{
switch(menu())
{
case 1:length=input(b);
if(length==-1) break;
else
saverecord(b,length);
break;
//case 2:length=loadrecord(b);
length=add(b,length);
saverecord(b,length);
break;
//case 3:length=loadrecord(b);
list(b,length);
break;
//case 4:length=loadrecord(b);
search_num(b,length);
break;
//case 5:length=loadrecord(b);
search_name(b,length);
break;
//case 6:length=loadrecord(b);
length=Delete(b,length);
saverecord(b,length);
break;
//case 7:length=loadrecord(b);
sort(b,length);
saverecord(b,length);
list(b,length);
break;
//case 8:length=loadrecord(b);
count(b,length);
saverecord(b,length);
break;
//case 9:length=loadrecord(b);
unborrow(b,length);
break;
case 0:exit(0);
}
}
}
int menu()
{ int c;
system("mode con:cols=400 lines=30000");
system("color 0b");
printf("\t\t\t\t\t-------------------------------------------\n");
printf("\t\t\t\t\t+ +\n");
printf("\t\t\t\t\t-------------------------------------------\n");
printf("\t\t\t\t\t\t\t ***************\n");
printf("\t\t\t\t\t\t\t 1. \n");
printf("\t\t\t\t\t\t\t 2. \n");
printf("\t\t\t\t\t\t\t 3. \n");
printf("\t\t\t\t\t\t\t 4. \n");
printf("\t\t\t\t\t\t\t 5. \n");
printf("\t\t\t\t\t\t\t 6. \n");
printf("\t\t\t\t\t\t\t 7. \n");
printf("\t\t\t\t\t\t\t 8. \n");
printf("\t\t\t\t\t\t\t 9. \n");
printf("\t\t\t\t\t\t\t 0. \n");
printf("\t\t\t\t\t\t\t ****************\n");
do{
printf("\n Enter your choice(0-9):");

if(scanf("%d",c)!=1)
{ while(getchar()!='\n')
continue;
continue;
}
}while(c9);
return c; }
int input(struct library book[])
{
int i,n;
system("cls");
printf("\t: \n");
scanf("\t\t\t\t%d",n);
system("cls");
printf("\t: \n");
for(i=0;ip)
count1++;
}
printf("\t:%d \n\n\n\n",count1);
printf("\t*****************************************************\n");
printf("\t press any key enter menu......\n");
printf("\t*****************************************************\n");
getchar();
getchar();
system("cls");
}
void unborrow(struct library bok[],int n)
{
}
void saverecord(struct library book[],int m)
{
int i;
FILE *fp;
if((fp=fopen("record.txt","w"))==NULL)
{
printf("can not open file\n");
exit(1);
}
for(i=0;i fwrite(book[i],sizeof(struct library),1,fp);
fclose(fp);
}
int loadrecord(struct library book[])
{
int n=0;
FILE *fp;
if((fp=fopen("record.txt","r"))==NULL)
{
printf("can not open file\n");
exit(0);
}
while(fread(book[n],sizeof(struct library),1,fp)) n++;
fclose(fp);
printf("!!!\n");
return n;
}

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!