第四题的输入写完了
This commit is contained in:
@@ -14,3 +14,7 @@ add_executable(test3 test3.cpp
|
||||
LinkList.h
|
||||
LinkList.cpp
|
||||
)
|
||||
add_executable(test4 test4.cpp
|
||||
LinkList.h
|
||||
LinkList.cpp
|
||||
)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//test3.cpp
|
||||
#include <iostream>
|
||||
#include"LinkList.h"
|
||||
#include"LinkList.h" //LinkList类见实验一
|
||||
using namespace std;
|
||||
|
||||
void alter_to_110_percent(bookList &l) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//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;
|
||||
}
|
||||
Reference in New Issue
Block a user