"C + + program" Library purchase system (remaining problems)

Source: Internet
Author: User

#include <iostream> #include <string>using namespace Std;class book{public:int num;float price;book *next;}; Book *head=null;bool Check (String str)//Check if it is a number {for (int i=0;i<str.length (); i++) {if (str[i]> ' 9 ' | | str[i]< ' 0 ') && (str[i]!= ')) return false;}} Book *creat () {*p1,*p2;p1=new book;head=p1;p2=p1;cout<< "Please enter the number of the books and end with 0" <<endl;string str;cin> >str;while (!check (str)) {cout<< "Input is not a number, please re-enter, press 0 to return to" &LT;&LT;ENDL;CIN&GT;&GT;STR; P1->num=atoi (Str.c_str ());//convert C + + strings through member functions C_str () to a C-formatted string; atoi convert it to an integer if (p1->num!=0) {cout<< " Please enter the price of the book "<<endl;cin>>str;while (!check (str)) {cout<<" is not a number entered, please re-enter, press 0 to return "<<endl;cin> >str;} P1->price=atof (Str.c_str ());//c++ string is converted to a C-formatted string through the member function c_str (); atof converts it to float}else {delete p1;p2=null;p2-> Next=null;head=null;return Head;} while (p1->num!=0) {p2=p1;p1=new book;cout<< "Please enter the number of the book, End with 0" <<endl;cin>>str;while (!check (str) ) {cout<< "Input is not a number, please re-enter, press 0 to return" <<endl;cin> >str;} P1->num=atoi (Str.c_str ());//convert C + + strings through member functions C_str () to a C-formatted string; atoi convert it to an integer if (p1->num!=0) {cout<< " Please enter the price of the book "<<endl;cin>>str;while (!check (str)) {cout<<" is not a number entered, please re-enter, press 0 to return "<<endl;cin> >str;} P1->num=atoi (Str.c_str ());//convert C + + strings through member functions C_str () to a C-formatted string; atoi convert it to integer}P2-&GT;NEXT=P1;} Delete P1;p2->next=null;return head;} void Showbook (Book*head) {cout<< "book Information:" <<endl;while (head) {cout<< "book Number" <


"C + + program" Library purchase system (remaining problems)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.