试读部分
题目信息: 每种图书包括下列三部分信息:书号,书名,价格 查找:根据指定的书号查找相关图书的信息,并返回该图书在表中的位置 插入 删除 修改:根据指定的书号,修改图书价格 排序:将表中图书按照价格由低到高排序 计数:计算表中图书数量 #include<iostream>
#include<string.h>
using namespace std;
typedef struct{
char no[20];
char name[50];
float price;
}ElemType;
typedef struct Node{
ElemType data;
struct Node *next;
}Node;
int Init(Node *&L){ //初始化表
L = new Node;
L->next = NULL;
return 1;
}
void Creat(Node *L){ //创建表
int n;
cout<<"please input the number of Elem: ";
cin>>n;
Node *s;
cout<<"please input BookNumber,BookName,BookPrice:"<<endl ;
for(int i = 0; i < n; i++){
s = new Node;
cin>>s->data.no>>s->data.name>>s->data.price;
s->next = L->next;
L->next = s;
}
}
int Show(Node *L){ //显示表中所有元素
cout<<"所有图书信息:"<<endl;
Node *p = L->next;
if(!p){
cout<<"表为空!";
return 0;
}
whi……
本文为 VIP 文章,已展示部分内容,开通 VIP 后查看全文
觉得这篇文章有帮助?
点个赞,或赞赏支持作者持续创作