Files
data-structures-and-algorithms/homework2/test4.cpp
T
2024-10-19 18:01:34 +08:00

32 lines
712 B
C++

//test4.cpp
#include<iostream>
#include"LinkList.h" //LinkList类见实验一
using namespace std;
void create_with_count(bookList &l, int count) {
bookNode *input = new bookNode;
input->next = NULL;
bookNode *temp = l;
for (int i = 0; i < count; i++) {
cin >> input->id >> input->name >> input->price;
if (temp == l) {
l->next = input;
} else {
temp->next = input;
}
temp = input;
input = new bookNode;
input->next = NULL;
}
}
int main() {
bookList books = new bookNode;
books->next = NULL;
int count;
cin >> count;
create_with_count(books, count);
display(&books);
return 0;
}