初步图书管理系统,顺序表建立。
代码:
# include <iostream>
# include <stdio.h>
# include <stdlib.h>
typedef int Elemtype;
#define maxsize 1000
using namespace std;
typedef struct
{
int id;
char name[30];
double price;
}book;
typedef struct
{
book *elem;
int length;
}Book;
int instat(Book &B)//初始化
{
B.elem=new book[maxsize];
if(!B.elem)return (-2);
B.length=0;
return 1;
}
void inBook(Book &B) //输入
{
cout<<"请确认输入图书总数:\n";
int n;
cin>>n;
cout<<"输入"<<n<<"本图书\n";
cout<<"请输入图书的id 书名