当前位置: 首页 > news >正文

商业网站的建设wordpress discuz插件

商业网站的建设,wordpress discuz插件,详细网络设计方案,wordpress端口更改这个图书管理系统包括了添加、查找、删除、编辑、显示和保存书籍信息的功能。书籍信息被保存在一个文本文件中#xff0c;在程序启动时从文件中加载#xff0c;退出程序时保存到文件中。用户可以通过命令行界面操作图书管理系统#xff0c;并进行相应的功能操作。 一、代码…这个图书管理系统包括了添加、查找、删除、编辑、显示和保存书籍信息的功能。书籍信息被保存在一个文本文件中在程序启动时从文件中加载退出程序时保存到文件中。用户可以通过命令行界面操作图书管理系统并进行相应的功能操作。 一、代码 #include stdio.h #include stdlib.h #include string.h#define MAX_BOOKS 100struct Book {char title[100];char author[100];int year; };struct Library {struct Book books[MAX_BOOKS];int count; };// 函数声明 void addBook(struct Library *library); void searchBook(struct Library library); void deleteBook(struct Library *library, char *title); void editBook(struct Library *library, char *title); void saveBooks(struct Library library, char *filename); void loadBooks(struct Library *library, char *filename); void displayBooks(struct Library library);int main() {struct Library library;library.count 0;loadBooks(library, books.txt); // 从文件加载书籍信息int choice;do {printf(\nLibrary Management System\n);printf(1. Add Book\n);printf(2. Search Book\n);printf(3. Delete Book\n);printf(4. Edit Book\n);printf(5. Display All Books\n);printf(6. Save Books\n);printf(7. Exit\n);printf(Enter your choice: );scanf(%d, choice);switch(choice) {case 1:addBook(library); // 添加书籍break;case 2:searchBook(library); // 查找书籍break;case 3: {char title[100];printf(Enter title of book to delete: );scanf(%s, title);deleteBook(library, title); // 删除书籍break;}case 4: {char title[100];printf(Enter title of book to edit: );scanf(%s, title);editBook(library, title); // 编辑书籍信息break;}case 5:displayBooks(library); // 显示所有书籍break;case 6:saveBooks(library, books.txt); // 保存书籍信息到文件break;case 7:printf(Exiting program.\n);break;default:printf(Invalid choice! Please enter a number from 1 to 7.\n);}} while (choice ! 7);return 0; }// 添加书籍 void addBook(struct Library *library) {if (library-count MAX_BOOKS) {printf(Library is full. Cannot add more books.\n);return;}struct Book newBook;printf(Enter title of book: );scanf(%s, newBook.title);printf(Enter author of book: );scanf(%s, newBook.author);printf(Enter year of publication: );scanf(%d, newBook.year);library-books[library-count] newBook;library-count;printf(Book added successfully.\n); }// 查找书籍 void searchBook(struct Library library) {char title[100];printf(Enter title of book to search: );scanf(%s, title);int found 0;for (int i 0; i library.count; i) {if (strcmp(library.books[i].title, title) 0) {printf(Book found:\n);printf(Title: %s\n, library.books[i].title);printf(Author: %s\n, library.books[i].author);printf(Year: %d\n, library.books[i].year);found 1;break;}}if (!found) {printf(Book not found.\n);} }// 删除书籍 void deleteBook(struct Library *library, char *title) {int found 0;for (int i 0; i library-count; i) {if (strcmp(library-books[i].title, title) 0) {for (int j i; j library-count - 1; j) {library-books[j] library-books[j 1];}library-count--;found 1;printf(Book deleted successfully.\n);break;}}if (!found) {printf(Book not found.\n);} }// 编辑书籍信息 void editBook(struct Library *library, char *title) {int found 0;for (int i 0; i library-count; i) {if (strcmp(library-books[i].title, title) 0) {printf(Enter new title of book: );scanf(%s, library-books[i].title);printf(Enter new author of book: );scanf(%s, library-books[i].author);printf(Enter new year of publication: );scanf(%d, library-books[i].year);found 1;printf(Book edited successfully.\n);break;}}if (!found) {printf(Book not found.\n);} }// 保存书籍信息到文件 void saveBooks(struct Library library, char *filename) {FILE *file fopen(filename, w);if (file NULL) {printf(Error opening file.\n);return;}for (int i 0; i library.count; i) {fprintf(file, %s %s %d\n, library.books[i].title, library.books[i].author, library.books[i].year);}fclose(file);printf(Books saved to file successfully.\n); }// 从文件加载书籍信息 void loadBooks(struct Library *library, char *filename) {FILE *file fopen(filename, r);if (file NULL) {printf(Error opening file.\n);return;}while (!feof(file) library-count MAX_BOOKS) {fscanf(file, %s %s %d\n, library-books[library-count].title, library-books[library-count].author, library-books[library-count].year);library-count;}fclose(file); }// 显示所有书籍 void displayBooks(struct Library library) {printf(Books in library:\n);for (int i 0; i library.count; i) {printf(Title: %s, Author: %s, Year: %d\n, library.books[i].title, library.books[i].author, library.books[i].year);} }二、程序分析 数据结构定义 Book 结构体 包含书籍的标题、作者和出版年份等信息。Library 结构体 包含一个 Book 结构体数组和一个计数器用于跟踪图书馆中的书籍数量。 主函数 main() 初始化图书馆 创建 Library 结构体变量并将书籍数量计数器初始化为 0。加载书籍信息 调用 loadBooks() 函数从文件中加载之前保存的书籍信息。用户界面 使用 do-while 循环显示菜单直到用户选择退出。菜单选项 用户可以选择添加书籍、查找书籍、删除书籍、编辑书籍、显示所有书籍、保存书籍到文件和退出程序。根据用户选择调用相应函数 根据用户选择调用不同的函数来执行相应的操作。 函数定义 添加书籍 (addBook())用户输入书籍的标题、作者和出版年份将新书籍添加到图书馆中。查找书籍 (searchBook())用户输入要查找的书籍标题系统根据输入查找并显示书籍的详细信息。删除书籍 (deleteBook())用户输入要删除的书籍标题系统根据输入删除相应的书籍。编辑书籍 (editBook())用户输入要编辑的书籍标题系统根据输入允许用户编辑书籍的标题、作者和出版年份。保存书籍 (saveBooks())将图书馆中的书籍信息保存到文件中以便下次程序启动时加载使用。加载书籍 (loadBooks())从文件中加载之前保存的书籍信息到图书馆中。显示所有书籍 (displayBooks())列出图书馆中所有书籍的详细信息。 文件操作 保存和加载书籍信息 使用文件操作函数 (fopen(), fclose(), fprintf(), fscanf()) 将书籍信息保存到文件或从文件中加载。 三、练习 把Library 结构体数组改为链表来实现。
http://www.zqtcl.cn/news/316916/

相关文章:

  • 弹幕网站开发难么招生网站建设的意义
  • 网站空间多大合适软件开发培训机构网课
  • 13个实用平面设计网站网络推广一个月的收入
  • 淮安企业网站制作校园网网络规划与设计方案
  • html完整网站开发自媒体平台账号注册
  • 厦门seo网站网站空间 群集
  • 青岛网站推广方案营销自动化平台
  • 管理信息系统与网站建设有什么区别python版wordpress
  • 济南市建设行政主管部门网站公众号登录入口官网
  • 深圳苏州企业网站建设服务企业做网站需要什么条件
  • 电脑什么网站可以做长图攻略公众号 微网站开发
  • 网站核检单怎么用小皮创建网站
  • 企业网站托管平台有哪些烟台高新区建设局网站
  • 石家庄网站做网站和县网页定制
  • 网站个人备案和企业备案潍坊公司注册网站
  • 建个网站的流程互联网裁员
  • 设置网站模板汉口网站建设公司
  • 网站对一个关键词做排名怎么做网站建设 图纸网
  • 什么网站比较吸引流量网页设计代码td
  • 克隆网站怎么做后台wordpress网站缩
  • 仁怀哪儿做网站泰安市建设局
  • 做网站和编程有关系吗手机怎么做电子书下载网站
  • 网站做关键词排名网站快速排名的方法
  • 有网站模板如何预览泉州app开发
  • 网站自助建站系统重庆皇华建设集团有限公司网站
  • 云速成美站做网站好吗汕头制作网站
  • 搜狗搜索网站提交入口在哪里做卖车网站
  • 河南省百城建设提质网站新人怎么做电商
  • 建设机械网站制作创建个人网站教案
  • 无锡网站推广装修风格大全2023新款