我们学C语言只学过一个学期,一共就八个单元,可今天在考试后学校突然要我们上实验课(像金工实习的课程),让我们编个程序,题目如下。我们压根就弄不懂题目,编程就更不用提了。老师说可以网上“参考参考”,现在大家都找到了,明天就要交了。我代码也找了一份,现在就缺报告。从来没有写过这种报告,望各位高人能帮忙下!
设计题目:2、图书信息管理系统设计
图书信息包括:登录号、书名、作者名、分类号、出版单位、出版时间、价格等。(一)功能要求:
(1)图书信息录入功能(图书信息用文件保存)--输入
(2)图书信息浏览功能--输出
(3)查询功能:(至少一种查询方式)
按书名查询
按作者名查询
(4)图书信息的修改(5)图书信息的删除(二)其它要求:
(1) 只能使用C/C++语言,源程序要有适当的注释,使程序容易阅读
(2) 至少采用文本菜单界面(如果能采用图形菜单界面更好)
(3) 学生可自动增加新功能模块(视情况可另外加分)
(4) 写出课程设计报告,具体要求见相关说明文档课程设计报告内容:
一、课程设计目的
二、课程设计内容
1、课程设计的题目及简介
2、设计说明
3、程序流图
4、程序清单
三、课程设计的要求
利用学到的编程知识和编程技巧,要求学生:
1、对系统进行功能模块分析、控制模块分析正确
2、系统设计要能完成题目所要求的功能。
3、编程简练,可用,尽可能的使系统的功能更加完善和全面
4、使用说明书、流程图要清楚。
5、特别要求自己独立完成。
四、课程设计总结
五、参考文献[size=18px]源代码:[/size]
#include<string>
using namespace std;
class myTime
{
public:
myTime();
int year;
int month;
};
class BOOK
{
public:
BOOK();
void Print() const;
int iLogoCode;
int iSortCode;
int iPrice;
string chBookname;
string chAuthor;
string chPress;
myTime time;
BOOK *next;
BOOK *nextHash;
private:
};
#include"library.h"
#include<iostream>
myTime::myTime():year(0),month(0)
{}
BOOK::BOOK()
{
next = NULL;
nextHash = NULL;
}
void BOOK::Print() const
{
cout<<endl<<"LogoCode: "<<iLogoCode<<endl;
cout<<"Bookname: "<<chBookname<<endl;
cout<<"Author: "<<chAuthor<<endl;
cout<<"SortCode: "<<iSortCode<<endl;
cout<<"chPress: "<<chPress<<endl;
cout<<"PubData: "<<time.year<<"/"<<time.month<<endl;
cout<<"Price: "<<iPrice<<endl<<endl;
}
#include<iostream>
#include<fstream>
#include"library.h"
#include<algorithm>
#include<conio.h>
#define NULLOFFILE -858993460
#define HASHLENGTH 10
//以散列法查询,定义散列表单元
struct LIST{
int key;
BOOK *p;
};
struct SEARCH_RESULT{
BOOK *p;
SEARCH_RESULT *next;
};
void getstr(ifstream &infile,string &chName)//读入由双引号("")包括的字符串,如书名、作者、出版社
{
string chTemp;
char chFlag=NULL;
while(chFlag != '"')
{
infile>>chTemp;
chName += chTemp;
chFlag = chName[chName._Mysize-1];
if(chFlag != '"')
{
chName += ' ';
}
}
chName.erase(remove(chName.begin(),chName.end(),'"'),chName.end());
}
void ReadIn(ifstream &infile,BOOK &book)//逐行读入文件中的图书信息,存入类单元链接表中
//每行代表一本书的信息,存入一个BOOK对象中,各个BOOK对象用指针顺序连接起来
{
BOOK *temp=&book,*position;
int isEnd;
char chFlag;
infile>>isEnd;
while(isEnd != NULLOFFILE)
{
temp->iLogoCode = isEnd;
infile>>chFlag;
if (chFlag == '"')
{
chFlag = NULL;
getstr(infile,temp->chBookname);
}
infile>>chFlag;
if (chFlag == '"')
{
chFlag = NULL;
getstr(infile,temp->chAuthor);
}
infile>>temp->iSortCode;
infile>>chFlag;
if (chFlag == '"')
{
chFlag = NULL;
getstr(infile,temp->chPress);
}
infile>>temp->time.year;
infile>>chFlag;
infile>>temp->time.month;
infile>>chFlag;
infile>>temp->iPrice;
while ((chFlag != '0') && (infile))//以字符变量读入文件流,直至读到下行登录号首字符'0'或文件流读完(infile == NULL)
infile>>chFlag;
if(chFlag == '0')
{
position = new BOOK;
temp->next = position;
temp = position;
infile>>isEnd;
}
else
isEnd = NULLOFFILE;
}
}
void Printbooklist(const BOOK &book)//仅打印登录号和书名(列表)
{
const BOOK *temp= &book;
do{
cout<<"LogoCode: "<<temp->iLogoCode<<"---"<<temp->chBookname<<endl;
temp = temp->next;
}while (temp);
}
void OrderHashing(LIST Namelist[HASHLENGTH],LIST Authorlist[HASHLENGTH],BOOK &book)//散列化book链表
{
BOOK *temp = &book;
int i;
do{
i = ((int)(temp->chBookname[0]) + 10000) % HASHLENGTH;//汉字头字符转成int为负,加10000去负号
if (Namelist[i].p == NULL)
{
Namelist[i].p = temp;
}
else
{
temp->nextHash = Namelist[i].p;
Namelist[i].p = temp;
}
temp = temp->next;
}while (temp != NULL);
}
SEARCH_RESULT *Search(const string strName,const LIST Namelist[HASHLENGTH])//按书名到散列表中查找
{
BOOK *temp;
int i,founds = 0;
bool tag = true;
struct SEARCH_RESULT *result = NULL,*position = result;
i = ((int)(strName[0]) + 10000) % HASHLENGTH;
temp = Namelist[i].p;
while ((temp != NULL)&&(strName.length() != 0))
{
for (i = 0;(i<(int)strName.length())&&(tag);i++)
{
tag = (strName[i] == temp->chBookname[i])? true : false;
}
if (tag)
{
founds++;
result = new SEARCH_RESULT;
result->p = temp;
result->next = position;
position = result;
}
temp = temp->nextHash;
tag = true;
}
if(founds == 0)
cout<<"error input or there is no such a book!"<<endl;
else
cout<<"Found "<<founds<<" book(s) which fit(s) your request!";
return position;
}
void DeleteStruct(SEARCH_RESULT *p)
{
if(p->next)
DeleteStruct(p->next);
else
delete p;
}
void main()
{
ifstream infile;
infile.open("D:/library.txt");
BOOK root;
SEARCH_RESULT *Booksearch,*p;
LIST Namelist[HASHLENGTH],Authorlist[HASHLENGTH];
for(int i=0;i<HASHLENGTH;i++)
{
Namelist[i].key = Authorlist[i].key = i;
Namelist[i].p = Authorlist[i].p = NULL;
}
ReadIn(infile,root);
OrderHashing(Namelist,Authorlist,root);
Printbooklist(root);
cout<<"Input the bookname which you want to get: ";
string strBookname;
char str[30];
cin.getline(str,30);
Booksearch = Search(str,Namelist);
p = Booksearch;
while(p)
{
p->p->Print();
p = p->next;
}
DeleteStruct(Booksearch);
getch();
}
设计题目:2、图书信息管理系统设计
图书信息包括:登录号、书名、作者名、分类号、出版单位、出版时间、价格等。(一)功能要求:
(1)图书信息录入功能(图书信息用文件保存)--输入
(2)图书信息浏览功能--输出
(3)查询功能:(至少一种查询方式)
按书名查询
按作者名查询
(4)图书信息的修改(5)图书信息的删除(二)其它要求:
(1) 只能使用C/C++语言,源程序要有适当的注释,使程序容易阅读
(2) 至少采用文本菜单界面(如果能采用图形菜单界面更好)
(3) 学生可自动增加新功能模块(视情况可另外加分)
(4) 写出课程设计报告,具体要求见相关说明文档课程设计报告内容:
一、课程设计目的
二、课程设计内容
1、课程设计的题目及简介
2、设计说明
3、程序流图
4、程序清单
三、课程设计的要求
利用学到的编程知识和编程技巧,要求学生:
1、对系统进行功能模块分析、控制模块分析正确
2、系统设计要能完成题目所要求的功能。
3、编程简练,可用,尽可能的使系统的功能更加完善和全面
4、使用说明书、流程图要清楚。
5、特别要求自己独立完成。
四、课程设计总结
五、参考文献[size=18px]源代码:[/size]
#include<string>
using namespace std;
class myTime
{
public:
myTime();
int year;
int month;
};
class BOOK
{
public:
BOOK();
void Print() const;
int iLogoCode;
int iSortCode;
int iPrice;
string chBookname;
string chAuthor;
string chPress;
myTime time;
BOOK *next;
BOOK *nextHash;
private:
};
#include"library.h"
#include<iostream>
myTime::myTime():year(0),month(0)
{}
BOOK::BOOK()
{
next = NULL;
nextHash = NULL;
}
void BOOK::Print() const
{
cout<<endl<<"LogoCode: "<<iLogoCode<<endl;
cout<<"Bookname: "<<chBookname<<endl;
cout<<"Author: "<<chAuthor<<endl;
cout<<"SortCode: "<<iSortCode<<endl;
cout<<"chPress: "<<chPress<<endl;
cout<<"PubData: "<<time.year<<"/"<<time.month<<endl;
cout<<"Price: "<<iPrice<<endl<<endl;
}
#include<iostream>
#include<fstream>
#include"library.h"
#include<algorithm>
#include<conio.h>
#define NULLOFFILE -858993460
#define HASHLENGTH 10
//以散列法查询,定义散列表单元
struct LIST{
int key;
BOOK *p;
};
struct SEARCH_RESULT{
BOOK *p;
SEARCH_RESULT *next;
};
void getstr(ifstream &infile,string &chName)//读入由双引号("")包括的字符串,如书名、作者、出版社
{
string chTemp;
char chFlag=NULL;
while(chFlag != '"')
{
infile>>chTemp;
chName += chTemp;
chFlag = chName[chName._Mysize-1];
if(chFlag != '"')
{
chName += ' ';
}
}
chName.erase(remove(chName.begin(),chName.end(),'"'),chName.end());
}
void ReadIn(ifstream &infile,BOOK &book)//逐行读入文件中的图书信息,存入类单元链接表中
//每行代表一本书的信息,存入一个BOOK对象中,各个BOOK对象用指针顺序连接起来
{
BOOK *temp=&book,*position;
int isEnd;
char chFlag;
infile>>isEnd;
while(isEnd != NULLOFFILE)
{
temp->iLogoCode = isEnd;
infile>>chFlag;
if (chFlag == '"')
{
chFlag = NULL;
getstr(infile,temp->chBookname);
}
infile>>chFlag;
if (chFlag == '"')
{
chFlag = NULL;
getstr(infile,temp->chAuthor);
}
infile>>temp->iSortCode;
infile>>chFlag;
if (chFlag == '"')
{
chFlag = NULL;
getstr(infile,temp->chPress);
}
infile>>temp->time.year;
infile>>chFlag;
infile>>temp->time.month;
infile>>chFlag;
infile>>temp->iPrice;
while ((chFlag != '0') && (infile))//以字符变量读入文件流,直至读到下行登录号首字符'0'或文件流读完(infile == NULL)
infile>>chFlag;
if(chFlag == '0')
{
position = new BOOK;
temp->next = position;
temp = position;
infile>>isEnd;
}
else
isEnd = NULLOFFILE;
}
}
void Printbooklist(const BOOK &book)//仅打印登录号和书名(列表)
{
const BOOK *temp= &book;
do{
cout<<"LogoCode: "<<temp->iLogoCode<<"---"<<temp->chBookname<<endl;
temp = temp->next;
}while (temp);
}
void OrderHashing(LIST Namelist[HASHLENGTH],LIST Authorlist[HASHLENGTH],BOOK &book)//散列化book链表
{
BOOK *temp = &book;
int i;
do{
i = ((int)(temp->chBookname[0]) + 10000) % HASHLENGTH;//汉字头字符转成int为负,加10000去负号
if (Namelist[i].p == NULL)
{
Namelist[i].p = temp;
}
else
{
temp->nextHash = Namelist[i].p;
Namelist[i].p = temp;
}
temp = temp->next;
}while (temp != NULL);
}
SEARCH_RESULT *Search(const string strName,const LIST Namelist[HASHLENGTH])//按书名到散列表中查找
{
BOOK *temp;
int i,founds = 0;
bool tag = true;
struct SEARCH_RESULT *result = NULL,*position = result;
i = ((int)(strName[0]) + 10000) % HASHLENGTH;
temp = Namelist[i].p;
while ((temp != NULL)&&(strName.length() != 0))
{
for (i = 0;(i<(int)strName.length())&&(tag);i++)
{
tag = (strName[i] == temp->chBookname[i])? true : false;
}
if (tag)
{
founds++;
result = new SEARCH_RESULT;
result->p = temp;
result->next = position;
position = result;
}
temp = temp->nextHash;
tag = true;
}
if(founds == 0)
cout<<"error input or there is no such a book!"<<endl;
else
cout<<"Found "<<founds<<" book(s) which fit(s) your request!";
return position;
}
void DeleteStruct(SEARCH_RESULT *p)
{
if(p->next)
DeleteStruct(p->next);
else
delete p;
}
void main()
{
ifstream infile;
infile.open("D:/library.txt");
BOOK root;
SEARCH_RESULT *Booksearch,*p;
LIST Namelist[HASHLENGTH],Authorlist[HASHLENGTH];
for(int i=0;i<HASHLENGTH;i++)
{
Namelist[i].key = Authorlist[i].key = i;
Namelist[i].p = Authorlist[i].p = NULL;
}
ReadIn(infile,root);
OrderHashing(Namelist,Authorlist,root);
Printbooklist(root);
cout<<"Input the bookname which you want to get: ";
string strBookname;
char str[30];
cin.getline(str,30);
Booksearch = Search(str,Namelist);
p = Booksearch;
while(p)
{
p->p->Print();
p = p->next;
}
DeleteStruct(Booksearch);
getch();
}
还明天就得给你??
Good Luck!!!
所以你想明天交报告,而今天还没开始写的话根本是没法保证质量的.