解答:
#include<iostream>
using namespace std;
#include<string>//string类头文件
#include<string.h>//memcpy头文件
long long MAXSIZE = 1000;
struct BOOK {
string ISBN;
string name;
float price;
};
int main() {
BOOK* book = new BOOK[MAXSIZE];
int currentPos = 0;
string input_ISBN;
string input_name;
float input_price;
while (true) {
cin >> input_ISBN >> input_name >> input_price;
if ("0" == input_ISBN) {
break;
}
else {
if (currentPos == MAXSIZE) {//原数组空间不够,则将空间扩大至二倍
BOOK* temp = new BOOK[MAXSIZE];
memcpy(temp, book, sizeof(book));
delete []book;
MAXSIZE *= 2;
book = new BOOK[MAXSIZE];
memcpy(book,