这个程序写得很顺利,话不多说直接放代码
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
//#pragma warning(disable:)
using namespace std;
struct information {
char booknum[20];
char bookname[20];
float price = 0.0f;
};
typedef struct LNode {
information data;
LNode *next;
}*Linklist;
void Create(Linklist &L, int *num) {
L = new LNode;
Linklist p, r;
p = new LNode;
L->next = p;
cout << "输入图书信息" << endl;
while (1) {
cin >> p->data.booknum >> p->data.bookname >> p->data.price;
if (p->data.booknum == 0 || p->data.bookname == 0 || p->data.price == 0) {
break;
}
r = p;
p = new LNode;
r->next = p;
(*num)++;
}
p->next = NULL;
}
int Insert(Linklist &L, int *place) {
int p1 = (*place)-1,p2=*place;
Linklist after=L,fore=L;
while (p1) {
fore = fo