#include <iostream>using namespace std;
class Addbook{
public:
int add();
private:
char a[2000]; //存放文件读进的东西
int i; //中间变量
char bookname[100]; //书名
char author[100]; //作者
char stock[2]; //库存
char num[3]; //编号
};
---------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
using namespace std;
class Check{
public:
int check();
private:
int i; //中间变量
char a[2000]; //存放文件读进的东西
};
---------------------------------------------------------------------------------------------------------------------------------------
#ifndef _BOOK_H_
#define _BOOK_H_
#include <iostream>
using namespace std;
#define _BOOK_H_
#include <iostream>
using namespace std;
class Book{
public:
void book();
private:
int i; //中间变量
char j[3]; //编号输入
char *p; //操作指针
char a[2000]; //存放文件读进的东西
};
#endif
public:
void book();
private:
int i; //中间变量
char j[3]; //编号输入
char *p; //操作指针
char a[2000]; //存放文件读进的东西
};
#endif
---------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>
using namespace std;
using namespace std;
class Delbook{
public:
int Del();
private:
char a[2000]; //存放文件读进的东西
int i; //中间变量
char *pa,*pb; //操作指针
char num[3]; //编号
char b1[2000]; //中间变量
char b2[2000]; //中间变量
};
---------------------------------------------------------------------------------------------------------------------------------------
public:
int Del();
private:
char a[2000]; //存放文件读进的东西
int i; //中间变量
char *pa,*pb; //操作指针
char num[3]; //编号
char b1[2000]; //中间变量
char b2[2000]; //中间变量
};
---------------------------------------------------------------------------------------------------------------------------------------
#ifndef __DISPLAY_H_
#define __DISPLAY_H_
#define __DISPLAY_H_
#include <iostream>
using namespace std;
using namespace std;
class Display{
public:
void DisplayZ(); //显示界面
private:
int i; //中间变量
};
#endif
public:
void DisplayZ(); //显示界面
private:
int i; //中间变量
};
#endif
---------------------------------------------------------------------------------------------------------------------------------------
#include "Addbook.h"
#include <fstream>
#include <string.h>
#include <windows.h>
#include <fstream>
#include <string.h>
#include <windows.h>
int Addbook::add()
{
system("CLS");
fstream file4;
file4.open("图书信息.txt",ios::in);
for(i=0;!file4.eof();i++){
a[i]=file4.get();
}
a[i-1]='\0';
file4.close();
cout<<a;
printf("请输入编号(接着上面的编号排):");
cin>>num;
printf("请输入书名:");
cin>>bookname;
printf("请输入作者名:");
cin>>author;
printf("请输入库存数(个位数):");
cin>>stock;
strcat(a,num);
strcat(a," ");
strcat(a,bookname);
strcat(a," ");
strcat(a,author);
strcat(a," ");
strcat(a,stock);
fstream file5;
file5.open("图书信息.txt",ios::out);
file5<<a<<endl;
file5.close();
printf("\n增加成功\n");
getchar();
getchar();
return 0;
}
{
system("CLS");
fstream file4;
file4.open("图书信息.txt",ios::in);
for(i=0;!file4.eof();i++){
a[i]=file4.get();
}
a[i-1]='\0';
file4.close();
cout<<a;
printf("请输入编号(接着上面的编号排):");
cin>>num;
printf("请输入书名:");
cin>>bookname;
printf("请输入作者名:");
cin>>author;
printf("请输入库存数(个位数):");
cin>>stock;
strcat(a,num);
strcat(a," ");
strcat(a,bookname);
strcat(a," ");
strcat(a,author);
strcat(a," ");
strcat(a,stock);
fstream file5;
file5.open("图书信息.txt",ios::out);
file5<<a<<endl;
file5.close();
printf("\n增加成功\n");
getchar();
getchar();
return 0;
}
==================================================================================
#include "Book.h"
#include <fstream>
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <windows.h>
#include <stdio.h>
#include <string.h>
void Book::book()
{
system("CLS");
fstream file2;
file2.open("图书信息.txt",ios::in);
for(i=0;!file2.eof();i++){
a[i]=file2.get();
}
a[i-1]='\0';
file2.close();
cout<<a;
while(1){
printf("请输入你要借的书籍(编号,两位数):");
cin>>j;
p=strstr(a,j);
if(p==NULL){
printf("查找不到\n");
continue;
}
else break;
}
p+=2; //指到空格位
while(1){
if(*p>='0'&&*p<='9'){
(*p)--;
break;
}
p++;
}
printf("\n\n借书成功\n");
fstream file3;
file3.open("图书信息.txt",ios::out);
file3<<a;
file3.close();
getchar();
getchar();
}
{
system("CLS");
fstream file2;
file2.open("图书信息.txt",ios::in);
for(i=0;!file2.eof();i++){
a[i]=file2.get();
}
a[i-1]='\0';
file2.close();
cout<<a;
while(1){
printf("请输入你要借的书籍(编号,两位数):");
cin>>j;
p=strstr(a,j);
if(p==NULL){
printf("查找不到\n");
continue;
}
else break;
}
p+=2; //指到空格位
while(1){
if(*p>='0'&&*p<='9'){
(*p)--;
break;
}
p++;
}
printf("\n\n借书成功\n");
fstream file3;
file3.open("图书信息.txt",ios::out);
file3<<a;
file3.close();
getchar();
getchar();
}
==================================================================================
#include "Check.h"
#include <stdio.h>
#include <fstream>
#include <windows.h>
using namespace std;
#include <stdio.h>
#include <fstream>
#include <windows.h>
using namespace std;
int Check::check(){
system("CLS");
fstream file1;
file1.open("图书信息.txt",ios::in);
for(i=0;!file1.eof();i++){
a[i]=file1.get();
}
a[i-1]='\0';
file1.close();
cout<<a;
printf("\n\n按任意键返回");
getchar();
getchar();
return 0;
}
==================================================================================
#include "Delbook.h"
#include <fstream>
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <windows.h>
#include <stdio.h>
#include <string.h>
int Delbook::Del()
{
system("CLS");
fstream file6;
file6.open("图书信息.txt",ios::in);
for(i=0;!file6.eof();i++){
a[i]=file6.get();
}
a[i-1]='\0';
file6.close();
cout<<a;
printf("请输入你要删除的书籍(编号):");
cin>>num;
pb=strstr(a,num);
for(pa=a,i=0;(pa+1)!=pb;pa++,i++){
b1[i]=*pa;
}
b1[i]='\0';
while(*pb!='\n'){
pb++;
}
for(i=0;*pb!='\0';pb++,i++){
b2[i]=*pb;
}
b2[i]='\0';
strcpy(a,b1);
strcat(a,b2);
fstream file7;
file7.open("图书信息.txt",ios::out);
file7<<a;
file7.close();
printf("\n删除成功\n");
getchar();
getchar();
return 0;
}
{
system("CLS");
fstream file6;
file6.open("图书信息.txt",ios::in);
for(i=0;!file6.eof();i++){
a[i]=file6.get();
}
a[i-1]='\0';
file6.close();
cout<<a;
printf("请输入你要删除的书籍(编号):");
cin>>num;
pb=strstr(a,num);
for(pa=a,i=0;(pa+1)!=pb;pa++,i++){
b1[i]=*pa;
}
b1[i]='\0';
while(*pb!='\n'){
pb++;
}
for(i=0;*pb!='\0';pb++,i++){
b2[i]=*pb;
}
b2[i]='\0';
strcpy(a,b1);
strcat(a,b2);
fstream file7;
file7.open("图书信息.txt",ios::out);
file7<<a;
file7.close();
printf("\n删除成功\n");
getchar();
getchar();
return 0;
}
==================================================================================
#include "Display.h"
#include <stdio.h>
#include <stdio.h>
void Display::DisplayZ()
{
printf("\n 图书管理系统\n");
printf("\n");
printf(" -------------------- 1.查看 --------------------\n\n");
printf(" -------------------- 2.订阅 --------------------\n\n");
printf(" -------------------- 3.增加 --------------------\n\n");
printf(" -------------------- 4.删除 --------------------\n\n\n\n");
printf("按0退出");
}
==================================================================================
#include "Display.h"
#include "Book.h"
#include "Addbook.h"
#include "Check.h"
#include "Delbook.h"
#include <iostream>
#include <windows.h>
#include <stdio.h>
using namespace std;
#include "Book.h"
#include "Addbook.h"
#include "Check.h"
#include "Delbook.h"
#include <iostream>
#include <windows.h>
#include <stdio.h>
using namespace std;
Display a;
Check b;
Book c;
Addbook d;
Delbook e;
Check b;
Book c;
Addbook d;
Delbook e;
int main()
{
while(1){
system("CLS");
a.DisplayZ();
printf("请输入你要选择的功能:");
int j;
cin>>j;
switch(j){
case 1:b.check();break;
case 2:c.book();break;
case 3:d.add();break;
case 4:e.Del();break;
default:
printf("输入有误");
system("CLS");
break;
}
}
return 0;
}
{
while(1){
system("CLS");
a.DisplayZ();
printf("请输入你要选择的功能:");
int j;
cin>>j;
switch(j){
case 1:b.check();break;
case 2:c.book();break;
case 3:d.add();break;
case 4:e.Del();break;
default:
printf("输入有误");
system("CLS");
break;
}
}
return 0;
}
==================================================================================