下载此文档

图书管理系统链表实现.doc


文档分类:管理/人力资源 | 页数:约5页 举报非法文档有奖
1/5
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/5 下载此文档
文档列表 文档介绍
#include <iostream> #include <string> using namespace std; class book { public: int num; float price; book *next; }; bool check(string str){ for(int i= 0;i< (); i++){ if((str[i] > '9' || str[i] < '0') && (str[i] != '.')){ return false; }} return true; } book *head = NULL; book *create(){ // 创建图书 book *p1; book *p2; p1= new book; head = p1; // 这句是增加的 p2= p1; cout << " 请输入图书编号,必须是数字,输入 0 则返回主菜单" << endl; string str; cin >> str; while(!check(str)){ cout << " 输入的不是数字,请重新输入" << endl; cin >> str; } p1 -> num = atoi (()); if(p1 -> num != 0){ cout << " 请输入图书价格" << endl; cin >> str; while(!check(str)){ cout << " 输入的不是数字,请重新输入" << endl; cin >> str; } p1 -> price = atof(()); } else { delete p1; p2= NULL; head = NULL; return head; } while(p1 -> num != 0){ p2= p1; p1= new book; cout << " 请输入图书编号,必须为数字,输入 0 则返回主菜单" << endl; string str; cin >> str; while(!check(str)){ cout << " 输入的不是数字,请重新输入,按 0 返回!!!" << endl; cin >> str; } p1 -> num = atoi(()); if(p1 -> num != 0){ cout << " 请输入图书价格,必须是数字" << endl; cin >> str; while(!check(str)){ cout << " 输入的不是数字,请重新输入,按 0 返回!!!" <<endl; cin >> str; } p1 -> price = atof(()); } p2 -> next = p1; } delete p1; p2 -> next = NULL; return head; } void showbook(book *head){ // 显示图书信息 cout << endl; cout << " 图书信息如下: " << endl; while (head){ cout << " 图书编号: " << head -> num << "\t"; cout << " 图书价格: " << head -> price << e

图书管理系统链表实现 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数5
  • 收藏数0 收藏
  • 顶次数0
  • 上传人yixingmaob
  • 文件大小0 KB
  • 时间2016-05-28