C语言程序设计(图书管理系统)//源代码一定要运行的起来 100
1、功能描述,新进图书基本信息的输入。2.图书基本信息的查询。3.对撤消图书信息的删除。4.为借书人办理注册。5.办理借书手续(非注册会员不能借书)。6.办理还书手续...
1、功能描述,新进图书基本信息的输入。
2. 图书基本信息的查询。
3. 对撤消图书信息的删除。
4. 为借书人办理注册。
5.办理借书手续(非注册会员不能借书)。
6.办理还书手续 展开
2. 图书基本信息的查询。
3. 对撤消图书信息的删除。
4. 为借书人办理注册。
5.办理借书手续(非注册会员不能借书)。
6.办理还书手续 展开
1个回答
展开全部
#ifndef _SIMPLE_BOOK_MANAGER_H
#define _SIMPLE_BOOK_MANAGER_H
typedef struct BookRecord
{
int index; //编号
char catalog[20]; //分类
char book_name[40]; //书名
char author[20]; //作者
char publisher[80]; //出版社
int quantity; //数量
float single_price; //单价
float total_price; //总价
}BookRecord, *PtrBookRecord;
typedef struct CatalogRecord
{
int index; //编号
char catalog[20]; //分类
int total_number; //总册数
}CatalogRecord, *PtrCatalogRecord;
#endif
void ReadBookRecord(BookRecord*, FILE*);
void FillRecord(char* line, BookRecord*);
FILE* open_file(const char* file_name);
void GetNumber(const char* file_name, char* number);
void print_main_menu();
char get_command();
void SearchAndDisplay(BookRecord*);
void Arrange(BookRecord*);
void PriceStat(BookRecord*, const char* output_file_name);
void NumberStat(BookRecord*, const char* output_file_name);
void print_search_and_disp_menu();
void SearchByName(BookRecord*);
void SearchByAuthor(BookRecord*);
void ShowAllBook(BookRecord*);
void print_head();
void print_book_record(BookRecord);
void print_arrange_menu();
void ArrangeByCatalog(BookRecord*);
void ArrangeByPublisher(BookRecord*);
int total_book_number;
int main(int argc, char* argv[])
{
FILE* fp;
char cmd;
char number[10] = {0};
char price_file_name[20] = {0};
char catalog_file_name[20] = {0};
BookRecord book_records[20];
int loop = 1;
memset(book_records, 0, sizeof(book_records));
if (argc >= 2)
{
fp = open_file(argv[1]);
GetNumber(argv[1], number);
}
else
{
char file_name[] = "DX0112.txt";
fp = open_file(file_name);
GetNumber(file_name, number);
}
if (fp == NULL)
{
printf("打开文件失败!");
return -1;
}
else
{
strcpy(price_file_name, "ZJ");
strcat(price_file_name, number);
strcat(price_file_name, ".txt");
strcpy(catalog_file_name, "ZL");
strcat(catalog_file_name, number);
strcat(catalog_file_name, ".txt");
}
ReadBookRecord(book_records, fp);
while (loop)
{
print_main_menu();
cmd = get_command();
switch(cmd)
{
case 'S': //查询显示
case 's':
SearchAndDisplay(book_records);
break;
case 'A': //排序
case 'a':
Arrange(book_records);
break;
case 'P': //统计总价
case 'p':
PriceStat(book_records, price_file_name);
break;
case 'N': //统计总册数
case 'n':
NumberStat(book_records, catalog_file_name);
break;
case 'Q':
case 'q':
loop = 0;
break;
default:
break;
}
}
fclose(fp);
}
#define _SIMPLE_BOOK_MANAGER_H
typedef struct BookRecord
{
int index; //编号
char catalog[20]; //分类
char book_name[40]; //书名
char author[20]; //作者
char publisher[80]; //出版社
int quantity; //数量
float single_price; //单价
float total_price; //总价
}BookRecord, *PtrBookRecord;
typedef struct CatalogRecord
{
int index; //编号
char catalog[20]; //分类
int total_number; //总册数
}CatalogRecord, *PtrCatalogRecord;
#endif
void ReadBookRecord(BookRecord*, FILE*);
void FillRecord(char* line, BookRecord*);
FILE* open_file(const char* file_name);
void GetNumber(const char* file_name, char* number);
void print_main_menu();
char get_command();
void SearchAndDisplay(BookRecord*);
void Arrange(BookRecord*);
void PriceStat(BookRecord*, const char* output_file_name);
void NumberStat(BookRecord*, const char* output_file_name);
void print_search_and_disp_menu();
void SearchByName(BookRecord*);
void SearchByAuthor(BookRecord*);
void ShowAllBook(BookRecord*);
void print_head();
void print_book_record(BookRecord);
void print_arrange_menu();
void ArrangeByCatalog(BookRecord*);
void ArrangeByPublisher(BookRecord*);
int total_book_number;
int main(int argc, char* argv[])
{
FILE* fp;
char cmd;
char number[10] = {0};
char price_file_name[20] = {0};
char catalog_file_name[20] = {0};
BookRecord book_records[20];
int loop = 1;
memset(book_records, 0, sizeof(book_records));
if (argc >= 2)
{
fp = open_file(argv[1]);
GetNumber(argv[1], number);
}
else
{
char file_name[] = "DX0112.txt";
fp = open_file(file_name);
GetNumber(file_name, number);
}
if (fp == NULL)
{
printf("打开文件失败!");
return -1;
}
else
{
strcpy(price_file_name, "ZJ");
strcat(price_file_name, number);
strcat(price_file_name, ".txt");
strcpy(catalog_file_name, "ZL");
strcat(catalog_file_name, number);
strcat(catalog_file_name, ".txt");
}
ReadBookRecord(book_records, fp);
while (loop)
{
print_main_menu();
cmd = get_command();
switch(cmd)
{
case 'S': //查询显示
case 's':
SearchAndDisplay(book_records);
break;
case 'A': //排序
case 'a':
Arrange(book_records);
break;
case 'P': //统计总价
case 'p':
PriceStat(book_records, price_file_name);
break;
case 'N': //统计总册数
case 'n':
NumberStat(book_records, catalog_file_name);
break;
case 'Q':
case 'q':
loop = 0;
break;
default:
break;
}
}
fclose(fp);
}
追问
没有用~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询