标题:图书出版管理系统求大神找一下改一下
只看楼主
baiyangjiyi
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-7-11
结帖率:0
已结贴  问题点数:20 回复次数:5 
图书出版管理系统求大神找一下改一下
#include<iostream.h>
#include<string>
#include<cstdlib>
int del();//删除图书信息
int insert();//添加图书信息
class Book;//book类前置声明
void change();//图书信息修改
void disp();//图书信息显示
void search_name();//按图书名称查询
void search_author();//按作者查询
void search();//图书信息查询
void menu();//主菜单
int sum;
const int N=50;
//以下是图书类
class Book
{ public:
Book(){};
Book(char nname[],char nauthor[],char ncompany[],char nsort[],int nnum,int nnumber,int nprice,int nyear,int nmonth,int nday)
{ name=nname;
company=ncompany;
author=nauthor;
sort=nsort;
num=nnum;
number=nnumber;
price=nprice;
year=nyear;
month=nmonth;
day=nday;
}
void display()
{
cout<<name<<"\t"<<num<<"\t"<<number<<"\t"<<sort<<"\t"<<author<<"\t"<<price<<"\t"<<year<<"-"<<month<<"-"<<day<<"\t"<<company<<endl;
}
char getname(){return name;}
char getauthor(){return author;}
int getnum(){return num;}
private:
char name[10];
char author[10];
char company[10];
char sort[10];
int num;
int number;
int price;
int year;
int month;
int day;
}
Book p[N];
int main()
{
Book a;
menu();
return 0;
}
//以下是主菜单
void menu()
{int select;
do{cout<<"************欢迎使用本系统!本系统功能如下:***********"<<endl;
cout<<" 1.图书信息输出"<<endl;
cout<<" 2.图书信息输入"<<endl;
cout<<" 3.图书信息查询"<<endl;
cout<<" 4.图书信息修改"<<endl;
cout<<" 5.图书信息删除"<<endl;
cout<<" 0.退出本系统"<<endl;
cout<<"*************************************"<<endl;
cout<<" 请输入您的选择: "<<endl;
do{ cin>>select;
if(select>5||select<0)
cout<<"您的选择有误!请重新输入:";
}while(select>5||select<0);
switch(select)
{case 0:break;
case 1:disp();break;
case 2:insert();break;
case 3:search();break;
case 4:change();break;
case 5:del();break;
}
}while(select!=0);
cout<<"文件已保存!!按任意键退出!再见!"<<endl;
}
//创建新图书
int insert()
{string name,company,author,sort;
int num,bumber,year,month,day,price;
int i=0,flag=1;
char select;
cout<<"请按向导输入要添加的图书信息!"<<endl;
do{
cout<<"图书编号:";
cin>>num;
cout<<"\n";
cout<<"图书名:";
cin>>name;
cout<<"\n";
cout<<"登录号:";
cin>>number;
cout<<"\n";
cout<<"作者名:";
cin>>author;
cout<<"\n";
cout<<"分类:";
cin>>sort;
cout<<"\n";
cout<<"价格:";
cin>>price;
cout<<"\n";
cout<<"出版单位:";
cin>>company;
cout<<"\n";
cout<<"出版时间(格式:XX-XX-XX):";
cin>>year>>"-">>month>>"-">>day;
cout<<"\n";
Book p[i](name,author,company,sort,num,number,price,year,month,day);
cout<<"图书信息已保存,继续添加请按Y或y"<<endl;
cin>>select;
if(select=='Y'||select=='y')
{flag=1;
i++;
}
else flag=0;
}while(flag==1);
sum=i;
return sum;
}
//删除图书信息
int del()
{int i,n,k;
cout<<"请输入您要删除的图书编号:"endl;
cin>>n;
for(i=0;i<=sum;i++)
{ if(p[i].getnum==n)
for(k=i,k<sum,k++)
p[i]=p[i+1];
}
cout<<"信息已删除!按任意键返回"<<endl;
sum-=1;
return sum;
}
//按图书名查询
void search_name(string str)
{i=0;
for(i=0;i<sum;i++)
if(strcmp(p[i].getname(),str)==0)
{cout<<"该图书信息如下:"<<endl;
p[i].display();
}
}
//按作者查询
void search_author(string str)
{i=0;
cout<<"该作者所著图书信息如下:"<<endl;
for(i=0;i<sum;i++)
if(strcmp(p[i].getauthor(),str)==0)
{
p[i].display();
}
}
//图书查询
void search()
{int select;
cout<<"**********本系统提供以下两种查询方式**********"<<endl;
cout<<" 1.按图书名称查询 "<<endl;
cout<<" 2.按作者姓名查询 "<<endl;
cout<<" 0.返回主菜单 "<<endl;
cout<<"***********************************************<<endl;
cout<<" 请输入您的选择:";
do{cin>>select;
if(select>2||select<0)
cout<<"您的选择有误,请重新输入:";
}while(select>2||select<0);
switch(select)
{case 0:menu();
case 1:search_name();
case 2:search_author();
}
}
void change(int n)
{string name,company,author,sort;
int num,bumber,year,month,day,price;
int flag=1,select;
do{ cout<<"请输入要更改的图书编号:";
cin>>n;
cout<<"请按向导输入新的图书信息!"<<endl;

cout<<"新的图书编号:";
cin>>num;
cout<<"\n";
cout<<"新的图书名:";
cin>>name;
cout<<"\n";
cout<<"新的登录号:";
cin>>number;
cout<<"\n";
cout<<"新的作者名:";
cin>>author;
cout<<"\n";
cout<<"新的分类:";
cin>>sort;
cout<<"\n";
cout<<"新的价格:";
cin>>price;
cout<<"\n";
cout<<"新的出版单位:";
cin>>company;
cout<<"\n";
cout<<"新的出版时间(格式:XX-XX-XX):";
cin>>year>>"-">>month>>"-">>day;
cout<<"\n";
Book p[n](name,author,company,sort,num,number,price,year,month,day);
cout<<"图书信息已保存,继续修改请按Y或y"<<endl;
cin>>select;
if(select=='Y'||select=='y')
{
flag=1;
}
else flag=0;
}while(flag==1);
cout<<"按任意键返回"<<endl;
}
错误提示:g:\c++\c++编译器\microsoft visual studio\myprojects\sds\sf.cpp(50) : error C2146: syntax error : missing ';' before identifier 'p'
g:\c++\c++编译器\microsoft visual studio\myprojects\sds\sf.cpp(50) : fatal error C1004: unexpected end of file found
搜索更多相关主题的帖子: 图书出版 管理系统 include search public 
2013-07-11 17:32
peach5460
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:武汉
等 级:贵宾
威 望:30
帖 子:2780
专家分:6060
注 册:2008-1-28
得分:7 
g:\c++\c++编译器\microsoft visual studio\myprojects\sds\sf.cpp(50) : error C2146: syntax error : missing ';' before identifier 'p'
p后面差分号

我总觉得授人以鱼不如授人以渔...
可是总有些SB叫嚣着:要么给代码给答案,要么滚蛋...
虽然我知道不要跟SB一般见识,但是我真的没修炼到宠辱不惊...
2013-07-11 17:39
baiyangjiyi
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-7-11
得分:0 
回复 2楼 peach5460
你加分好试一下
2013-07-11 17:42
love云彩
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:青藏高原
等 级:贵宾
威 望:53
帖 子:3663
专家分:11416
注 册:2012-11-17
得分:7 
第二个错误是文件查找不期待出现的结尾。

思考赐予新生,时间在于定义
2013-07-11 19:22
baiyangjiyi
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2013-7-11
得分:0 
回复 4楼 love云彩
那这个怎么改呢
2013-07-11 19:35
xieyajiang
Rank: 2
等 级:论坛游民
帖 子:24
专家分:65
注 册:2011-12-8
得分:7 
//字符串赋值strcpy函数,类创建对象不要直接创建P[i],这样会创建i个对象


#include<iostream.h>
#include<string>
#include<cstdlib>
int del();//删除图书信息
int insert();//添加图书信息
class Book;//book类前置声明
void change();//图书信息修改
void disp();//图书信息显示
void search_name();//按图书名称查询
void search_author();//按作者查询
void search();//图书信息查询
void menu();//主菜单
int sum;
const int N=50;
//以下是图书类
class Book
{ public:
Book(){};
Book(char nname[],char nauthor[],char ncompany[],char nsort[],int nnum,int nnumber,int nprice,int nyear,int nmonth,int nday)
{ strcpy(name,nname);
strcpy(company,ncompany);
strcpy(author,nauthor);
strcpy(sort,nsort);
num=nnum;
number=nnumber;                                 
price=nprice;
year=nyear;
month=nmonth;
day=nday;
}                                                                              
char* getname(Book &L){return L.name;}
char* getauthor(Book &L){return L.author;}
int getnum(){return num;}
private:
char name[10];
char author[10];
char company[10];
char sort[10];
int num;
int number;
int price;
int year;
int month;
int day;
};

Book p[N];
int main()
{
Book a;
menu();
return 0;
}
//以下是主菜单
void menu()
{int select;
do{cout<<"************欢迎使用本系统!本系统功能如下:***********"<<endl;
cout<<" 1.图书信息输出"<<endl;
cout<<" 2.图书信息输入"<<endl;
cout<<" 3.图书信息查询"<<endl;
cout<<" 4.图书信息修改"<<endl;
cout<<" 5.图书信息删除"<<endl;
cout<<" 0.退出本系统"<<endl;
cout<<"*************************************"<<endl;
cout<<" 请输入您的选择: "<<endl;
do{ cin>>select;
if(select>5||select<0)
cout<<"您的选择有误!请重新输入:";
}while(select>5||select<0);
switch(select)
{case 0:break;
case 1:disp();break;
case 2:insert();break;
case 3:search();break;
case 4:change();break;
case 5:del();break;
}
}while(select!=0);
cout<<"文件已保存!!按任意键退出!再见!"<<endl;
}
//创建新图书
int insert()
{char *name,*company,*author,*sort;
int num,number,year,month,day,price;
int i=0,flag=1;
char select;
cout<<"请按向导输入要添加的图书信息!"<<endl;
do{
cout<<"图书编号:";
cin>>num;
cout<<"\n";
cout<<"图书名:";
cin>>name;
cout<<"\n";
cout<<"登录号:";
cin>>number;
cout<<"\n";
cout<<"作者名:";
cin>>author;
cout<<"\n";
cout<<"分类:";
cin>>sort;
cout<<"\n";
cout<<"价格:";
cin>>price;
cout<<"\n";
cout<<"出版单位:";
cin>>company;
cout<<"\n";
cout<<"出版时间(格式:XX-XX-XX):";
cin>>year>>"-">>month>>"-">>day;
cout<<"\n";
Book q(name,author,company,sort,num,number,price,year,month,day);
p[i]=q;
cout<<"图书信息已保存,继续添加请按Y或y"<<endl;
cin>>select;
if(select=='Y'||select=='y')
{flag=1;
i++;
}
else flag=0;
}while(flag==1);
sum=i;
return sum;
}
//删除图书信息
int del()
{int i,n,k;
cout<<"请输入您要删除的图书编号:"<<endl;
cin>>n;
for(i=0;i<=sum;i++)
{ if(p[i].getnum()==n)
for(k=i;k<sum;k++)
p[i]=p[i+1];
}
cout<<"信息已删除!按任意键返回"<<endl;
sum-=1;
return sum;
}
//按图书名查询
void search_name(Book &L,char* str)
{int i=0;
for(i=0;i<sum;i++)
if(strcmp(p[i].getname(L),str)==0)
{cout<<"该图书信息如下:"<<endl;
//p[i].display();
}
}
//按作者查询
void search_author(Book &L,char* str)
{
int i=0;
cout<<"该作者所著图书信息如下:"<<endl;
for(i=0;i<sum;i++)
if(strcmp(p[i].getauthor(L),str)==0)
{
//p[i].display();
}
}
//图书查询
void search()
{int select;
cout<<"**********本系统提供以下两种查询方式**********"<<endl;
cout<<" 1.按图书名称查询 "<<endl;
cout<<" 2.按作者姓名查询 "<<endl;
cout<<" 0.返回主菜单 "<<endl;
cout<<"***********************************************"<<endl;
cout<<" 请输入您的选择:";
do{cin>>select;
if(select>2||select<0)
cout<<"您的选择有误,请重新输入:";
}while(select>2||select<0);
switch(select)
{case 0:menu();
case 1:search_name();
case 2:search_author();
}
}
void change(int n)
{char *name,*company,*author,*sort;
int num,number,year,month,day,price;
int flag=1,select;
do{ cout<<"请输入要更改的图书编号:";
cin>>n;
cout<<"请按向导输入新的图书信息!"<<endl;

cout<<"新的图书编号:";
cin>>num;
cout<<"\n";
cout<<"新的图书名:";
cin>>name;
cout<<"\n";
cout<<"新的登录号:";
cin>>number;
cout<<"\n";
cout<<"新的作者名:";
cin>>author;
cout<<"\n";
cout<<"新的分类:";
cin>>sort;
cout<<"\n";
cout<<"新的价格:";
cin>>price;
cout<<"\n";
cout<<"新的出版单位:";
cin>>company;
cout<<"\n";
cout<<"新的出版时间(格式:XX-XX-XX):";
cin>>year>>"-">>month>>"-">>day;
cout<<"\n";
Book q(name,author,company,sort,num,number,price,year,month,day);
p[n]=q;
cout<<"图书信息已保存,继续修改请按Y或y"<<endl;
cin>>select;
if(select=='Y'||select=='y')
{
flag=1;
}
else flag=0;
}while(flag==1);
cout<<"按任意键返回"<<endl;
}


2013-07-12 22:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-417124-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.058751 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved