C language programming a book management, I also want to use C language to program a book management system,
#includeusing namespace std;
const int N = 25;//Define 20 books
struct Book {
char name[25];
char author[15];
char price[7];
char publisher[20];
char isbn[20];
};
int ii = 19;
Book book[N] = { { "Red and Black","Stenda","26.00","Changjiang Literature and Art Publishing House","978-7-5354-5003-6" },
{ "Zhang Boling's Painting Biography", "Liang Jisheng", "35.00", "Sichuan Education Press", "978-7-5408-5623-6" },
{ "Four Generations of Flowers", "Shen Yulun", "49.80", "Hunan Literature and Art Publishing House", "978-7-5404-7718-9" },
{ "Peking University's Etiquette Class", "Duan Jianlin", "39.80", "Foreign Language Press", "978-7-119-08439-8" },
{ "Les Miserables", "Hugo", "44.00", "Northern Literature and Art Publishing House", "978-7-5317-3049-1" },
{ "Okay okay", "Big Ice", "39.00", "Hunan Literature and Art Publishing House", "978-7-5404-7689-2" },
{ "Qianqiu", "Luoluo", "28.80", "Changjiang Literature and Art Publishing House", "978-7-5354-5060-9" },
{ "Accompany Anthony through the long years","Anthony","28.80","Changjiang Literature and Art Publishing House","978-7-5354-6205-3" },
{ "The True Story of Liu Bang", "Zhou Qiyuan", "52.80", "Chinese Literature and History Publishing House", "978-7-5034-5145-4" },
{"Little Prince","Saint-Exupéry","24.00","Hunan Children's Publishing House","978-7-5562-0Exam-1"},
{ "Besieged City", "Qian Zhongshu", "19.00", "People's Literature Publishing House", "978-7-02-009000-6" },
{ "Jieyou grocery store", "Higashino Keigo", "39.50", "Nanhai Publishing House", "978-7-5442-7087-3" },
{ "The Kite Runner", "Hosseini", "29.00", "Shanghai People's Publishing House", "978-7-208-06164-4" },
{ "Ferryman", "McFall", "36.00", "Baihuazhou Literature and Art Publishing House", "978-7-550-01324-7" },
{ "Myth", "Zhu Dake", "35.00", "Oriental Publishing House", "978-7-5060-5278-8" },
{ "In the name of the people", "Zhou Meisen", "46.90", "Beijing October Literature and Art Publishing House", "978-7-5302-1619-4" },
{ "Ten Notes on Nights", "Ma Shilu", "29.80", "Jinghua Publishing House", "978-7-5502-2550-3" },
{ "Wukong Biography", "Where is this day", "32.00", "Beijing United Publishing House", "978-7-5502-7767-0" },
{ "Heroes", "Miyabe Miyuki", "29.90", "Qingdao Publishing House", "978-7-5436-6784-6" },
{ "White Night Walk","Higashino Keigo","39.50","Nanhai Publishing House","978-7-5442-5860-9" } };
void inquiremenu() {
system("cls");
int y = 0;
printf("************");
printf("1. Book number query");
printf("2. Book title query");
printf("3. Author query");
printf("4. Press query");
printf("Please select (1~4): Enter to confirm");
scanf("%d", &y);
int i;
switch (y) {
case 1: {
char x[20];
system("cls");
printf("Please enter the search book number");
scanf("%s", &x);
bool fg = 0;
for (i = 0; i if (strcmp(book[i].isbn,x) == 0) {
printf("Found");
fg = 1;
printf("Book Title: %s, Author: %s, Price: %s, Publisher: %s, Book Number: %s", book[i].name, book[i].author, book[i]. price, book[i].publisher, book[i].isbn);
}
}//Search by book number
if (!fg)printf("Not found/n");
break;
}
case 2: {
char j[25];
system("cls");
printf("Please enter the search book title");
scanf("%s", &j);
bool fg = 0;
for (i = 0; i if (strcmp(j, book[i].name) == 0) {
printf("Found");
fg = 1;
printf("Book Title: %s, Author: %s, Price: %s, Publisher: %s, Book Number: %s", book[i].name, book[i].author, book[i]. price, book[i].publisher, book[i].isbn);
}
}//Search by title
if (!fg)printf("Not found/n");
break;
}
case 3: {
char k[15];
system("cls");
printf("Please enter to find the author");
scanf("%s", &k);
bool fg = 0;
for (i = 0; i if (strcmp(k, book[i].author) == 0) {
printf("已找到");
fg = 1;
printf("书名:%s,作者:%s,价格:%s,出版社:%s,书号:%s", book[i].name, book[i].author, book[i].price, book[i].publisher, book[i].isbn);
}
}//按作者查询
if (!fg)printf("未找到/n");
break;
}
case 4: {
char z[20];
system("cls");
scanf("%s", &z);
bool fg = 0;
printf("请输入查找出版社");
for (i = 0; i if (strcmp(z, book[i].publisher) == 0) {
printf("已找到");
fg = 1;
printf("书名:%s,作者:%s,价格:%s,出版社:%s,书号:%s", book[i].name, book[i].author, book[i].price, book[i].publisher, book[i].isbn);
}
}//按出版社查询
if (!fg)printf("未找到/n");
break;
}
}
}//查询函数
void addbook() {
system("cls");
printf("请输入书名");
scanf("%s", &book[ii + 1].name);
printf("请输入作者");
scanf("%s", &book[ii + 1].author);
printf("请输入价格");
scanf("%s", &book[ii + 1].price);
printf("请输入出版社");
scanf("%s", &book[ii + 1].publisher);
printf("请输入书号");
scanf("%s", &book[ii + 1].isbn);
++ii;
}//添加图书
void information() {
int i;
for (i = 0; i printf("");
printf("书名:%s,作者:%s,价格:%s,出版社:%s,书号:%s", book[i].name, book[i].author, book[i].price, book[i].publisher, book[i].isbn);
}
}//显示所有图书信息
int main() {
int accept, input_error_flag;
system("cls");
printf("******图书查询系统******");
printf("************************");
printf("******1.图书查询*******");
printf("******2.添加图书***");
printf("******3.图书信息*****");
printf("******4.退 出******");
printf("************************");
printf("****请输入选择(1~4):*****");
input_error_flag = 0;
do {
if (input_error_flag == 1)
printf("输入错误!!! 重新输入:");
printf("输入:1~4):");
fflush(stdin);//输入缓冲区清空
scanf("%d", &accept);
input_error_flag = 1;
} while (accept 4);
switch (accept)
{
case 0:
case 1:inquiremenu(); break;
case 2:addbook(); break;
case 3:information(); break;
case 4:printf("退出"); break;
default:system("cls");
}
return 0;
}