图书管理系统 ,可以增删查改,VS2013编译
#include<iostream>
#include <iomanip>
#include "string"
using namespace std;
#define OK 1
#define ERROR 0
#define OVERFLOW -2
#define MAXSIZE 10000
typedef struct
{
char no[20];
char name[50];
char author[20];
}Book;
typedef struct
{
Book *elem;
int length;
}SqList;
void Printf(SqList &L);
int InitList(SqList &L)
{
L.elem = new Book[MAXSIZE];
if(!L.elem) exit(OVERFLOW);
L.length = 0;
return OK;
}
int GetElem(SqList L,int i,Book &e) //取出
{
if(i<1 || i>L.length) return ERROR;
e = L.elem[i-1];
return OK;
}
void LocateElem(SqList L) //查找
{
Book e;
int i;
char n = 0;
while (1)
{
cout << "输入1按书号查找,输入2按书名查找,输入3按作者名查找,输入4按序号查找,输入#返回上一级:" << endl;
cin >> n;
if (n == '#')
break;
if (n == '1')
{
cout << "请输入要查找的书号:";
cin >> e.no;
for (i = 0; i < L.length; i++)
{
if (strcmp(L.elem[i].no , e.no) == 0)
{
cout << L.elem[i].no << " " << L.elem[i].name << " " << L.elem[i].author << endl;
break;
}
}
if (i >= L.length)
cout << "查无