把输入函数修好了
This commit is contained in:
@@ -11,6 +11,30 @@ bool isEmpty(bookList *l) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void create(bookList &l) {
|
||||
bookNode *input = new bookNode;
|
||||
input->next = NULL;
|
||||
bookNode *temp = l; // 从头节点开始
|
||||
bool flag = true;
|
||||
|
||||
while (flag) {
|
||||
cin >> input->id >> input->name >> input->price;
|
||||
|
||||
if (input->id == "0" && input->name == "0" && input->price == 0) {
|
||||
flag = false;
|
||||
delete input;
|
||||
} else {
|
||||
if (temp == l) {
|
||||
l->next = input;
|
||||
} else {
|
||||
temp->next = input;
|
||||
}
|
||||
temp = input;
|
||||
input = new bookNode;
|
||||
input->next = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void display(bookList *l) {
|
||||
if (isEmpty(l)) {
|
||||
|
||||
Reference in New Issue
Block a user