#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" <<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->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->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)