c语言图书信息管理系统 - 爱问答

(爱问答)

c语言图书信息管理系统

1)问题描述:

本系统可以用来进行简单的图书信息管理,具体管理操作包括t图书信息的录入、添加、显示、查找、删除、修改、排序和保存等功能。

2)功能描述:

(1)本系统采用结构体数组,每个数据的结构应当包括书名、书号、作者名、种类名、出版单位、出版时间、价格、图书册数、借阅。

(2)系统功能:

a.  图书入库:即添加新的图书信息记录。

b.  图书显示: 按图书编号顺序或按图书名称显示图书信息。

(可以扩充功能,如添加按图书种类显示、按作者名显示等。)

c.  图书查询:输入图书名称或图书编号则显示相关图书的信息

(可以扩充功能,如添加按图书种类查询、按作者名查询等。)

d.  图书修改:即修改已录入的图书信息记录。

e.  图书报废:即删除不需要的图书信记录息。

f.  图书信息保存: 当添加、修改、删除信息后,应该将其存入文件。

g.退出系统。

(3)系统使用说明:执行一个具体的功能之后,程序将重新显示功能菜单。系统的功能并不限于上述,可以对其进行扩充完善,如在对信息进行修改和删除时,可以考虑系统的安全性,在执行前若输入正确密码,才可进行操作。

3)测试数据:

    图书数目>=20


#include <stdio.h>#include <string.h>#define Total 20 typedef struct Time {    int year;    int month;    int day;}Time; struct Book {    int bookID;    char bookName[20];    char authorName[20];    int groupID;    char publishHouse[20];    Time publishTime;    double price;    int isVisible;  //1-正常况, 0-被删除} book[Total]; int count = 0; void inputInfo(){    printf("Please input the number of books: ");    scanf("%d", &count);    for (int i = 0; i < count; i ++) {        printf("Book %d: ", i + 1);        printf("book ID:");        scanf("%d", &book[i].bookID);        getchar();        printf("book name:");        scanf("%s", book[i].bookName);        getchar();        printf("author name:");        scanf("%s", book[i].authorName);        printf("group ID:");        scanf("%d", &book[i].groupID);        getchar();        printf("publishing house:");        scanf("%s", book[i].publishHouse);        printf("publishing time:");        scanf("%d.%d.%d", &book[i].publishTime.year, &book[i].publishTime.month, &book[i].publishTime.day);        printf("book price:");        scanf("%lf", &book[i].price);        book[i].isVisible = 1;    }    printf("Input Complete! ");} void outputInfo(){    printf("BookID BookName Author GroupID PublishHouse Time price ");    for (int i = 0; i < count; i ++) {        if (book[i].isVisible == 1) {            printf("%d ", book[i].bookID);            printf("%s ", book[i].bookName);            printf("%s ", book[i].authorName);            printf("%d ", book[i].groupID);            printf("%s ", book[i].publishHouse);            printf("%d.%d.%d ",book[i].publishTime.year, book[i].publishTime.month, book[i].publishTime.day);            printf("%.2lf ", book[i].price);            printf(" ");        }    }} void searchByBookName(){    char name[20];    printf("Please input the name of the book:");    scanf("%s", name);    int i;    for (i = 0; i < count; i ++) {        if (strcmp(book[i].bookName, name) == 0 && book[i].isVisible == 1) {            printf("----------------------------------------------- ");            printf("--  You are viewing the book: %s ", name);            printf("-- Book ID: %d ", book[i].bookID);            printf("-- Author: %s ", book[i].authorName);            printf("-- Group ID: %d ", book[i].groupID);            printf("-- Publishing House: %s ", book[i].publishHouse);            printf("-- Publishing Time: %d.%d.%d ",book[i].publishTime.year, book[i].publishTime.month, book[i].publishTime.day);            printf("-- Book Price: %lf ", book[i].price);            printf("----------------------------------------------- ");            return;        }    }    if (i == count)        printf("Not find the book you want. ");} void searchByAuthorName(){    char name[20];    printf("Please input the author's name of the book:");    scanf("%s", name);    int i;    for (i = 0; i < count; i ++) {        if (strcmp(book[i].authorName, name) == 0 && book[i].isVisible == 1) {            printf("----------------------------------------------- ");            printf("--  You are viewing the book: %s ", name);            printf("-- Book ID: %d ", book[i].bookID);            printf("-- Author: %s ", book[i].authorName);            printf("-- Group ID: %d ", book[i].groupID);            printf("-- Publishing House: %s ", book[i].publishHouse);            printf("-- Publishing Time: %d.%d.%d ",book[i].publishTime.year, book[i].publishTime.month, book[i].publishTime.day);            printf("-- Book Price: %lf ", book[i].price);            printf("----------------------------------------------- ");            return;        }    }    if (i == count)        printf("Not find the book you want. ");} void quertBook(){    int choice;    printf("Do you want to search by book name or by author name? 0-book,1-author:");    scanf("%d", &choice);    if (choice == 0)        searchByBookName();    if (choice == 1)        searchByAuthorName();} void deleteByBookName(){    char name[20];    printf("Please input the name of the book:");    scanf("%s", name);    int i;    for (i = 0; i < count; i ++) {        if (strcmp(book[i].bookName, name) == 0 && book[i].isVisible == 1) {            book[i].isVisible = 0;            printf("Delete Complete! ");            return;        }    }    if (i == count)        printf("The book doesn't exist. ");} void deleteByBookID(){    int ID;    printf("Please input the ID of the book:");    scanf("%d", &ID);    int i;    for (i = 0; i < count; i ++) {        if (book[i].bookID == ID && book[i].isVisible == 1) {            book[i].isVisible = 0;            printf("Delete Complete! ");            return;        }    }    if (i == count)        printf("The book doesn't exist. "); } void deleteBook(){    int choice;    printf("Do you want to delete by book name or by book ID? 0-name,1-ID:");    scanf("%d", &choice);    if (choice == 0)        deleteByBookName();    if (choice == 1)        deleteByBookID();} void modifyByBookName(){    char name[20];    printf("Please input the name of the book:");    scanf("%s", name);    int i;    for (i = 0; i < count; i ++) {        if (strcmp(book[i].bookName, name) == 0 && book[i].isVisible == 1) {            printf("You are modifying the book: %s", book[i].bookName);            printf("Please reinput the entire info of the book: ");            printf("Book %d: ", i + 1);            printf("book ID:");            scanf("%d", &book[i].bookID);            getchar();            printf("book name:");            scanf("%s", book[i].bookName);            getchar();            printf("author name:");            scanf("%s", book[i].authorName);            printf("group ID:");            scanf("%d", &book[i].groupID);            getchar();            printf("publishing house:");            scanf("%s", book[i].publishHouse);            printf("publishing time:");            scanf("%d.%d.%d", &book[i].publishTime.year, &book[i].publishTime.month, &book[i].publishTime.day);            printf("book price:");            scanf("%lf", &book[i].price);            book[i].isVisible = 1;            printf("Modification Complete! ");            return;        }    }    if (i == count)        printf("The book doesn't exist. ");} void modifyByBookID(){    int ID;    printf("Please input the ID of the book:");    scanf("%d", &ID);    int i;    for (i = 0; i < count; i ++) {        if (book[i].bookID == ID && book[i].isVisible == 1) {            printf("You are modifying the book: %s", book[i].bookName);            printf("Please reinput the entire info of the book: ");            printf("Book %d: ", i + 1);            printf("book ID:");            scanf("%d", &book[i].bookID);            getchar();            printf("book name:");            scanf("%s", book[i].bookName);            getchar();            printf("author name:");            scanf("%s", book[i].authorName);            printf("group ID:");            scanf("%d", &book[i].groupID);            getchar();            printf("publishing house:");            scanf("%s", book[i].publishHouse);            printf("publishing time:");            scanf("%d.%d.%d", &book[i].publishTime.year, &book[i].publishTime.month, &book[i].publishTime.day);            printf("book price:");            scanf("%lf", &book[i].price);            book[i].isVisible = 1;            printf("Modification Complete! ");            return;        }    }    if (i == count)        printf("The book doesn't exist. ");} void modifyBook(){    int choice;    printf("Do you want to modify by book name or by book ID? 0-name,1-ID:");    scanf("%d", &choice);    if (choice == 0)        modifyByBookName();    if (choice == 1)        modifyByBookID();} void insertBook(){    printf("Please input the info of the book you want to insert ");    printf("Book %d: ", count + 1);    printf("book ID:");    scanf("%d", &book[count].bookID);    getchar();    printf("book name:");    scanf("%s", book[count].bookName);    getchar();    printf("author name:");    scanf("%s", book[count].authorName);    printf("group ID:");    scanf("%d", &book[count].groupID);    getchar();    printf("publishing house:");    scanf("%s", book[count].publishHouse);    printf("publishing time:");    scanf("%d.%d.%d", &book[count].publishTime.year, &book[count].publishTime.month, &book[count].publishTime.day);    printf("book price:");    scanf("%lf", &book[count].price);    book[count].isVisible = 1;    count ++;    printf("Insert Complete! ");} void menu(){    printf("--------------------------------- ");    printf("--  1 - input data             -- ");    printf("--  2 - output data            -- ");    printf("--  3 - search for a book      -- ");    printf("--  4 - delete a book          -- ");    printf("--  5 - modify info of a book  -- ");    printf("--  6 - insert data            -- ");    printf("--  0 - exit                   -- ");    printf("--------------------------------- ");     } int main() {    int choice;    menu();    scanf("%d", &choice);    while (choice != 0){        switch (choice) {            case 1:                inputInfo();                break;            case 2:                outputInfo();                break;            case 3:                quertBook();                break;            case 4:                deleteBook();                break;            case 5:                modifyBook();                break;            case 6:                insertBook();                break;            default:                break;        }        menu();        scanf("%d", &choice);    }    return 0;}


有现成的软件或找专业的人员定制也行的

相关标签:c语言

下一篇:请问机械师笔记本怎么样呀?在用的朋友能说说吗?

上一篇:dnf下载完内存够安装不了

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?