資源簡介
c++課程設計作業,源碼。可以運行,沒有文檔。可以作為同學們比較初級的參考。

代碼片段和文件信息
//?Library.cpp?:?定義控制臺應用程序的入口點。
//
#include?“stdafx.h“
#include?
#include?
#include?
#include??
#include?
#include?
#include?
using?namespace?std;
const?int?READER=100;//讀者上限,為了簡化編程,我們定義了數據的上限
const?int?BOOK=100;//圖書上線
const?int?MAX=3;//每位讀者最多借3本書
class?Bookborrow//借書類
{
private:
int?bookNumber;//索書號
int?readNumber;//借書號
struct?BW{
int?bnum;
int?rnum;
}borrowStore[MAX];
int?n;//計數器
public:
Bookborrow()
{
::ifstream?readin;
int?i=0;
/* char?str[200];*/
readin.open(“bookborrow.txt“ios::in);
if(readin.fail())
{
return?;
}
else
{
while(!readin.eof())
{
/*?readin.getline?(strsizeof(str));*/
?????????readin>>borrowStore[i].rnum?;
?readin>>borrowStore[i].bnum?;
?
?i++;
}
}
n=i;
readin.close();
}
int?bookborrow(int?rnumint?bnum);
int?bookreturn(int?bnum);
void?restore();
};
class?Book
{
?private:
?string?bookName;//書名
?bool?isBorrowed;//是否借出
?int?n;
?struct?B{
?int?num;
?string?name;
?bool?flag;
?}bookStore[BOOK];
?public:
??int?bookNumber;//索書號
?Book()
?{
?::ifstream?readin;
?int?i=0;
readin.open(“book.txt“ios::in);
if(readin.fail())
{
return?;
}
else
{
while(!readin.eof())
{
?????????readin>>bookStore[i].num?;
?readin>>bookStore[i].name?;
?readin>>bookStore[i].flag?;
?i++;
}
}
readin.close();
n=i;
?}
?bool?BookBorrow(int?rnumstring?bname);//借書讀者號&書名
?
?void?BookReturn(int?bnum);//還書
?void?restore();//數據更新
?void?BookQuery();//查找圖書
?void?BookFine();//超期罰款
?
};
class?Reader
{
private:
int?readerNumber;//借書號
string?readerName;//人名
int?borrowNumber;//已借書書冊數,規定每人借書不得超過3本
struct?R{
int?num;
string?name;
int?bnum;
}readerStore[READER];//存放讀取txt數據的結構體數組
int?n;
public:
Reader()
{
::ifstream?readin;
int?i=0;
readin.open(“reader.txt“ios::in);
if(readin.fail())
{
return?;
}
else
{
while(!readin.eof())
{
?????????readin>>readerStore[i].num?;
?readin>>readerStore[i].name?;
?readin>>readerStore[i].bnum?;
?i++;
}
}
n=i;
readin.close();
}
void?ReaderBorrow(int?rnumstring?bname);
void?ReaderReturn(int?rnum);
void?restore();//重寫
void?ReaderQuery();
};
bool?Book::BookBorrow?(int?rrumstring?bname)
{
bool?isAllow=false;//默認書不可借
bool?isOn=false;//默認書不存在
int?i=0;
for(i=0;i {
if(bname==bookStore[i].name)
{
isOn=true;
if(bookStore[i].flag)
isAllow=true;
break;
}
}
if(!isOn)
{
cout<<“本書不存在!“< }
else
if(!isAllow)
{
cout<<“本書已被借走!“< }
else
{
bookStore[i].flag?=0;
bookNumber=bookStore[i].num?;
bookName=bookStore[i].name?;
restore();
}
return?isAllow;
}
void?Book::BookReturn(int?bnum)
{
int?flag1=0;
for(int?i=0;i
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????109??2011-12-31?22:49??Library\Debug\book.txt
?????文件?????????10??2011-12-31?22:49??Library\Debug\bookborrow.txt
?????文件?????117248??2013-06-19?13:14??Library\Debug\Library.exe
?????文件?????631240??2013-06-19?13:14??Library\Debug\Library.ilk
?????文件?????936960??2013-06-19?13:14??Library\Debug\Library.pdb
?????文件?????????30??2011-12-31?22:52??Library\Debug\reader.txt
?????文件????2949120??2013-06-19?13:12??Library\ipch\library-99a5e447\library-4044d7c1.ipch
?????文件????????130??2011-12-31?22:33??Library\Library\book.txt
?????文件?????????25??2011-12-31?22:33??Library\Library\bookborrow.txt
?????文件???????1258??2013-06-19?13:14??Library\Library\Debug\cl.command.1.tlog
?????文件???????8908??2013-06-19?13:14??Library\Library\Debug\CL.read.1.tlog
?????文件????????754??2013-06-19?13:14??Library\Library\Debug\CL.write.1.tlog
?????文件???????1494??2011-12-30?02:57??Library\Library\Debug\Library.Build.CppClean.log
?????文件????????406??2011-12-30?02:57??Library\Library\Debug\Library.exe.em
?????文件????????472??2011-12-30?02:57??Library\Library\Debug\Library.exe.em
?????文件????????381??2011-12-31?22:32??Library\Library\Debug\Library.exe.intermediate.manifest
?????文件?????????50??2013-06-19?13:14??Library\Library\Debug\Library.lastbuildstate
?????文件????????927??2013-06-19?13:14??Library\Library\Debug\Library.log
?????文件?????356458??2013-06-19?13:14??Library\Library\Debug\Library.obj
?????文件????1245184??2013-06-19?13:14??Library\Library\Debug\Library.pch
?????文件????????204??2011-12-30?02:57??Library\Library\Debug\Library_manifest.rc
?????文件??????????2??2013-06-19?13:14??Library\Library\Debug\li
?????文件??????????2??2013-06-19?13:14??Library\Library\Debug\li
?????文件??????????2??2013-06-19?13:14??Library\Library\Debug\li
?????文件??????????2??2013-06-19?13:14??Library\Library\Debug\li
?????文件??????????2??2013-06-19?13:14??Library\Library\Debug\li
?????文件??????????2??2013-06-19?13:14??Library\Library\Debug\li
?????文件??????????2??2013-06-19?13:14??Library\Library\Debug\li
?????文件??????????2??2013-06-19?13:14??Library\Library\Debug\li
?????文件??????????2??2013-06-19?13:14??Library\Library\Debug\li
............此處省略43個文件信息
- 上一篇:tiny4412裸機相關程序
- 下一篇:GPS-廣播星歷計算衛星位置
評論
共有 條評論