Current location - Training Enrollment Network - Books and materials - 4. The realization of the book modification function. Construct a book structure as shown below. Structure book {intisn charbook _ name [20]; tea
4. The realization of the book modification function. Construct a book structure as shown below. Structure book {intisn charbook _ name [20]; tea
# including "iostream"

Use? Namespace? std

typedef? struct? book

{

int? Isbn// Book Index

Charles? book _ name[20]; //Book name

Charles? auther[20]; //book author

Floating? Price; //Book price

} book;

int? Master ()

{

Books? Book [5];

Charles? tmp _ book _ name[20];

Bull? IsFind? =? Fake; //Mark whether the book is found.

For what? (int? I = 0; ? I<5; ? i++)

{

Cout & lt& lt "Please enter the number?" & lt& ltI+ 1 & lt; & lt"? The information of this book "

Cout & lt& lt "Please enter the book index:";

CIN & gt; & gt book [me]. isbn

Cout & lt& lt Please enter the name of this book:

CIN & gt; & gt book [me]. book _ name

Cout & lt& lt Please enter the author of this book:;

CIN & gt; & gt book [me]. auther

Cout & lt& lt "Please enter the price of this book:";

CIN & gt; & gt book [me]. Price;

cout & lt& ltendl

}

Cout & lt& lt "Please enter the name of the book you are looking for:"

CIN & gt; & gttmp _ book _ name

For what? (int? I = 0; ? I<5; ? I++)// loop search book.

{

If (strcmp (book [I]). Book _ name, tmp _ book _ name) = = 0)//strcmp compares whether two strings are equal.

{

IsFind? =? True;

Cout & lt& lt successfully found the book, please enter the modification information.

Cout & lt& lt The index has been modified to:'';

CIN & gt; & gt book [me]. isbn

Cout & lt& lt "was revised as";

CIN & gt; & gt book [me]. auther

Cout & lt& lt "The price is changed to";

CIN & gt; & gt book [me]. Price;

Cout & lt& lt "Modified successfully"

Break;

}

}

If (! IsFind)

{

Cout & lt& lt "There is no such book, thank you for coming!" & lt& ltendl

}

Return? 0;

}