| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 603 人关注过本帖
标题:[讨论]帮小弟改改程序吧,实在不知道怎么改了,谢谢啦!!
只看楼主 加入收藏
yy054201
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-7-23
收藏
 问题点数:0 回复次数:5 
[讨论]帮小弟改改程序吧,实在不知道怎么改了,谢谢啦!!

帮小弟看看程序是哪里错了吧!!!大家提出来,谢谢啦!!!小弟不会了!!!在线等!!!
谢谢!!!
头文件
#ifndef Keshe_H_
#define Keshe_H_
#include <iomanip>
#include <string>
#include <iostream>
using namespace std;
class Hangkong{
private:
int num;
char start[20];
char over[20];
char time[10];
int count;
public:
Hangkong(int=0,int=0);
void input();
void print();
void save();
void read();
void search();
void shanchu();
void dingpiao();
void tuipiao();
};
#endif

源文件
# include "Keshe.h"
const int MaxSize=100;
const int m=0;
const int N=100;
int i;
Hangkong arr[MaxSize];
#define PRINT "%-d%12s%12s%10s%12d\n",arr[i].num,arr[i].start,arr[i].over,arr[i].time,arr[i].count
Hangkong::Hangkong(int vnum,int vcount){
num=vnum;
count=vcount;

}

void Hangkong::input(){
char f[]="2008china";
int y;
cout<<"请输入密码并以回车键结束:";
cin>>f;
if(strcmp(f,"2008china")==0)
{
cout<<"请依次输入航班信息(机票数位0结束输入):";
cout<<"完成输入信息请键入w以回车键结束";
cout<<"--------------------------------------------------------------------------"<<endl;
for(i=0;i<N;i++)
{

cout<<"请输入航班号:";
cin>>arr[i].num;
cout<<"请输入起始站:";
cin>>arr[i].start;
cout<<"请输入终点站:";
cin>>arr[i].over;
cout<<"请输入时间:";
cin>>arr[i].time;
cout<<"请输入机票数(机票数为0结束输入):"<<m<<endl;
cin>>arr[i].count;
m++;

cout<<"第%d个信息已经输完是否继续?按任意键继续,按 0结束"<<m<<endl;
cin>>y;
if(y==0)
{
save();
print();
break;
}

}

}
else
cout<<"输入密码错误!请检查您的密码是否正确!谢谢!再见!"<<endl;
}

void save()
{
FILE *fp,*fp1;
if((fp=fopen("chen.dat","wb"))==NULL)
{
cout<<"创建文件失败!";
getchar();
return;
}
if((fp1=fopen("hao.dat","wb"))==NULL)
{
cout<<"创建文件失败!";
getchar();
return;
}

for(i=0;i<m;i++)
if(fwrite(&arr[i],sizeof(class Hangkong),1,fp)==0)
cout<<"向文件输入数据失败!";
fcout(fp1,"%d",m);
fclose(fp);
fclose(fp1);
}

void read()
{
FILE *fp,*fp1;
if((fp=fopen("chen.dat","rb"))==NULL)
{
cout<<"出错,请检查文件是否存在,按任意键返回住菜单";
getchar();
}
if((fp1=fopen("hao.dat","rb"))==NULL)
{
cout<<"创建文件失败!";
getchar();
return;
}
fscanf(fp1,"%d",&m);
fclose(fp1);
for(i=0;i<m;i++)
{
fread(&arr[i],sizeof(class Hangkong),1,fp);
}
fclose(fp);
}

void Hangkong::print(){
char w[10];
read();
cout<<"航班号 起始站 终点站 时间 机票数"<<endl;
for(i=0;i<m;i++)
{
cout(PRINT);
}
cout<<"请按任意键回车键结束返回上层菜单以:"<<endl;
cin>>w;
}

void Hangkong::search(){
char name1[20];
char name2[20];
char ii[10];
int n,no;
do
{
cout<<"请选择查找方式:";
cout<<"1.按航班号查找:";
cout<<"2.按终点站查找:";
cout<<"3.按航线查找:";
cout<<"0.返回:";
cout<<"请在0-3中选择:";
cout<<"按其他键以回车键结束返回主菜单:";
cin>>n;
if(n==0)
break;
switch(n)
{
case 1:
cout<<"请输入航班号:";
cin>>no;
break;
case 2:
cout<<"请输入终点站名称:";
cin>>name2;
break;
case 3:
cout<<"请输入起始站名称:";
cin>>name1;
cout<<"请输入终点站名称:";
cin>>name2;
break;
}
read();
for(i=0;i<m;i++)
{
if(strcmp(arr[i].over,name1)==0||strcmp(arr[i].over,name2)==0)
{
cout<<"\n查找航班信息成功!";
cout<<"航班号 起始站 终点站 时间 机票数\n";
cout(PRINT);
break;
}
if(arr[i].num==no)
{
cout<<"\n查找航班信息成功!";
cout<<"航班号 起始站 终点站 时间 机票数\n";
cout(PRINT);
break;
}
}
no=0;
cout<<"没有您需要的信息或查找完毕:";
cout<<"是否继续查找?请键入yes或no以回车键结束";
cin>>ii;
}while(strcmp(ii,"yes")==0);
}

void Hangkong::shanchu(){
char name1[20];
char name2[20];
char ii[10];
char f[]="2008china";
int no,n;
cout<<"请输入密码并以回车键结束:";
cin>>f;
if(strcmp(f,"2008china")==0)
{
do
{
cout<<"请选择删除以方式回车键结束:";
cout<<"*1.按航班号删除\n\n";
cout<<"*2.按航线删除\n\n";
cout<<"*0.返回\n\n";
cout<<"请在0-2中选择以回车键结束:";
cin>>n;
if(n==0)
break;
switch(n)
{
case 1:
cout<<"请输入航班号:";
cin>>no;
break;
case 2:
cout<<"请输入起始站 名称:";
cin>>name1;
cout<<"请输入终点站名称:";
cin>>name2;
break;
}
for(i=0;i<m;i++)
{
if(arr[i].num==no||strcmp(arr[i].start,name1)==0&&strcmp(arr[i].over,name2)==0)
{
arr[i]=arr[m-1];
m--;
}

}
cout<<"查找完毕或没有这个信息"<<endl;
cout<<"是否继续删除"<<endl;
cout<<"请键入yes或no以回车键结束"<<endl;
cin>>ii;
save();
if(!strcmp(ii,"yes"))
cout<<"请按任意键以回车键结束返回上层菜单:";
break;
}while(n!=1&&n!=2&&n!=3&&n!=4&&n!=0);
}
else
cout<<"对不起密码错误!您不是管理员,不能使用此项功能!谢谢!再见!";
}

void Hangkong::dingpiao(){
int n;
char a[10];
do
{
search();
cout<<"请输入您要订的机票数以回车键结束:";
cin>>n;
if(n<0)
{
cout<<"请输入有效的机票数!";
break;
}
if(arr[i].count!=0&&arr[i].count>=n)
{
arr[i].count=arr[i].count-n;
save();
cout<<"订票成功!";
break;
}
if(arr[i].count<n)
{
cout<<"请输入有效的机票数:";
break;
}
cout<<"是否继续? 请输入yes或no以回车键结束:";
cin>>a;
}while(!strcmp(a,"yes"));
}

void Hangkong::tuipiao(){
int n;
char a[10];
do
{
search();
cout<<"请输入您要退的机票数目:";
cin>>n;
if(n<0)
cout<<"请输入有效的机票数!";
arr[i].count=arr[i].count+n;
save();
cout<<"退票成功!";
cout<<"是否继续? 请键入yes或no以回车键结束:";
cin>>a;
}while(!strcmp(a,"yes"));
getchar();
}

主函数
# include "Keshe.h"
void main()
{

int j;
cout<<" ★---您好,欢迎进入中国民航管理系统!---★\n";
cout<<"================================================================================"<<endl;
do
{
cout<<" -------- ☆ 1.输入航班信息 ☆-------- ";
cout<<" -------- ☆ 2.浏览航班信息 ☆-------- ";
cout<<" -------- ☆ 3.修改航班信息 ☆-------- ";
cout<<" -------- ☆ 4.查找航班信息 ☆-------- ";
cout<<" -------- ☆ 5.删除航班信息 ☆-------- ";
cout<<" -------- ☆ 6.订票信息 ☆-------- ";
cout<<" -------- ☆ 7.退票信息 ☆-------- ";
cout<<" -------- ☆ 0.退出 ☆-------- ";
cout<<"================================================================================"<<endl;
cout<<"请在0-7中选择以回车键结束:";
cin>>j;
switch(j)
{
case 1: Hangkong::input();
break;
case 2: Hangkong::print();
break;
case 3: Hangkong::xiugai();
break;
case 4: Hangkong::search();
break;
case 5: Hangkong::shanchu();
break;
case 6: Hangkong::dingpiao();
break;
case 7: Hangkong::tuipiao();
break;
case 0:
break;
}
}while(j!=0);
cout<<"谢谢使用,再见!"<<endl;
}

搜索更多相关主题的帖子: 改改 
2007-07-23 17:49
maoguoqing
Rank: 6Rank: 6
来 自:重庆
等 级:贵宾
威 望:28
帖 子:2980
专家分:19
注 册:2005-12-5
收藏
得分:0 
你得把出现的问题描述一下。。

天行健,君子以自强不息!!QQ:68660681
2007-07-23 18:02
yy054201
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-7-23
收藏
得分:0 
回复:(maoguoqing)你得把出现的问题描述一下。。

--------------------Configuration: keshe - Win32 Debug--------------------
Compiling...
keshe.cpp
E:\keshe\keshe.cpp(37) : error C2105: '++' needs l-value
E:\keshe\keshe.cpp(74) : error C2065: 'fcout' : undeclared identifier
E:\keshe\keshe.cpp(108) : error C2064: term does not evaluate to a function
E:\keshe\keshe.cpp(155) : error C2064: term does not evaluate to a function
E:\keshe\keshe.cpp(162) : error C2064: term does not evaluate to a function
E:\keshe\keshe.cpp(211) : error C2105: '--' needs l-value
main.cpp
E:\keshe\main.cpp(23) : error C2352: 'Hangkong::input' : illegal call of non-static member function
e:\keshe\keshe.h(16) : see declaration of 'input'
E:\keshe\main.cpp(25) : error C2352: 'Hangkong::print' : illegal call of non-static member function
e:\keshe\keshe.h(17) : see declaration of 'print'
E:\keshe\main.cpp(27) : error C2039: 'xiugai' : is not a member of 'Hangkong'
e:\keshe\keshe.h(7) : see declaration of 'Hangkong'
E:\keshe\main.cpp(27) : error C2065: 'xiugai' : undeclared identifier
E:\keshe\main.cpp(29) : error C2352: 'Hangkong::search' : illegal call of non-static member function
e:\keshe\keshe.h(20) : see declaration of 'search'
E:\keshe\main.cpp(31) : error C2352: 'Hangkong::shanchu' : illegal call of non-static member function
e:\keshe\keshe.h(21) : see declaration of 'shanchu'
E:\keshe\main.cpp(33) : error C2352: 'Hangkong::dingpiao' : illegal call of non-static member function
e:\keshe\keshe.h(22) : see declaration of 'dingpiao'
E:\keshe\main.cpp(35) : error C2352: 'Hangkong::tuipiao' : illegal call of non-static member function
e:\keshe\keshe.h(23) : see declaration of 'tuipiao'
执行 cl.exe 时出错.

keshe.exe - 1 error(s), 0 warning(s)

这就是运行后,VC提示的错误,谢谢你了!!!!

2007-07-23 18:07
yy054201
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-7-23
收藏
得分:0 

--------------------Configuration: keshe - Win32 Debug--------------------
Compiling...
keshe.cpp
E:\keshe\keshe.cpp(37) : error C2105: '++' needs l-value
E:\keshe\keshe.cpp(74) : error C2065: 'fcout' : undeclared identifier
E:\keshe\keshe.cpp(108) : error C2064: term does not evaluate to a function
E:\keshe\keshe.cpp(155) : error C2064: term does not evaluate to a function
E:\keshe\keshe.cpp(162) : error C2064: term does not evaluate to a function
E:\keshe\keshe.cpp(211) : error C2105: '--' needs l-value
main.cpp
E:\keshe\main.cpp(23) : error C2352: 'Hangkong::input' : illegal call of non-static member function
e:\keshe\keshe.h(16) : see declaration of 'input'
E:\keshe\main.cpp(25) : error C2352: 'Hangkong::print' : illegal call of non-static member function
e:\keshe\keshe.h(17) : see declaration of 'print'
E:\keshe\main.cpp(27) : error C2039: 'xiugai' : is not a member of 'Hangkong'
e:\keshe\keshe.h(7) : see declaration of 'Hangkong'
E:\keshe\main.cpp(27) : error C2065: 'xiugai' : undeclared identifier
E:\keshe\main.cpp(29) : error C2352: 'Hangkong::search' : illegal call of non-static member function
e:\keshe\keshe.h(20) : see declaration of 'search'
E:\keshe\main.cpp(31) : error C2352: 'Hangkong::shanchu' : illegal call of non-static member function
e:\keshe\keshe.h(21) : see declaration of 'shanchu'
E:\keshe\main.cpp(33) : error C2352: 'Hangkong::dingpiao' : illegal call of non-static member function
e:\keshe\keshe.h(22) : see declaration of 'dingpiao'
E:\keshe\main.cpp(35) : error C2352: 'Hangkong::tuipiao' : illegal call of non-static member function
e:\keshe\keshe.h(23) : see declaration of 'tuipiao'
执行 cl.exe 时出错.

keshe.exe - 1 error(s), 0 warning(s)

这就是运行后,VC提示的错误,谢谢你了!!!!

2007-07-23 18:17
maoguoqing
Rank: 6Rank: 6
来 自:重庆
等 级:贵宾
威 望:28
帖 子:2980
专家分:19
注 册:2005-12-5
收藏
得分:0 

#include <iomanip>
#include <string>
#include <iostream>
using namespace std;
class Hangkong{
private:
int num;
char start[20];
char over[20];
char time[10];
int count;
public:
Hangkong(int=0,int=0);
void input();
void print();
void save();
void read();
void search();
void shanchu();
void dingpiao();
void tuipiao();
};


const int MaxSize=100;
int m=0;
const int N=100;
int i;
Hangkong arr[MaxSize];
#define PRINT "%-d%12s%12s%10s%12d\n",arr[i].num,arr[i].start,arr[i].over,arr[i].time,arr[i].count
Hangkong::Hangkong(int vnum,int vcount){
num=vnum;
count=vcount;

}

void Hangkong::input(){
char f[]="2008china";
int y;
cout<<"请输入密码并以回车键结束:";
cin>>f;
if(strcmp(f,"2008china")==0)
{
cout<<"请依次输入航班信息(机票数位0结束输入):";
cout<<"完成输入信息请键入w以回车键结束";
cout<<"--------------------------------------------------------------------------"<<endl;
for(i=0;i<N;i++)
{

cout<<"请输入航班号:";
cin>>arr[i].num;
cout<<"请输入起始站:";
cin>>arr[i].start;
cout<<"请输入终点站:";
cin>>arr[i].over;
cout<<"请输入时间:";
cin>>arr[i].time;
cout<<"请输入机票数(机票数为0结束输入):"<<m<<endl;
cin>>arr[i].count;
m++;

cout<<"第%d个信息已经输完是否继续?按任意键继续,按 0结束"<<m<<endl;
cin>>y;
if(y==0)
{
save();
print();
break;
}

}

}
else
cout<<"输入密码错误!请检查您的密码是否正确!谢谢!再见!"<<endl;
}

void Hangkong::save()
{
FILE *fp,*fp1;
if((fp=fopen("chen.dat","wb"))==NULL)
{
cout<<"创建文件失败!";
getchar();
return;
}
if((fp1=fopen("hao.dat","wb"))==NULL)
{
cout<<"创建文件失败!";
getchar();
return;
}

for(i=0;i<m;i++)
if(fwrite(&arr[i],sizeof(class Hangkong),1,fp)==0)
cout<<"向文件输入数据失败!";
fprintf(fp1,"%d",m);
fclose(fp);
fclose(fp1);
}

void Hangkong::read()
{
FILE *fp,*fp1;
if((fp=fopen("chen.dat","rb"))==NULL)
{
cout<<"出错,请检查文件是否存在,按任意键返回住菜单";
getchar();
}
if((fp1=fopen("hao.dat","rb"))==NULL)
{
cout<<"创建文件失败!";
getchar();
return;
}
fscanf(fp1,"%d",&m);
fclose(fp1);
for(i=0;i<m;i++)
{
fread(&arr[i],sizeof(class Hangkong),1,fp);
}
fclose(fp);
}

void Hangkong::print(){
char w[10];
read();
cout<<"航班号 起始站 终点站 时间 机票数"<<endl;
for(i=0;i<m;i++)
{
cout<<PRINT;
}
cout<<"请按任意键回车键结束返回上层菜单以:"<<endl;
cin>>w;
}

void Hangkong::search(){
char name1[20];
char name2[20];
char ii[10];
int n,no;
do
{
cout<<"请选择查找方式:";
cout<<"1.按航班号查找:";
cout<<"2.按终点站查找:";
cout<<"3.按航线查找:";
cout<<"0.返回:";
cout<<"请在0-3中选择:";
cout<<"按其他键以回车键结束返回主菜单:";
cin>>n;
if(n==0)
break;
switch(n)
{
case 1:
cout<<"请输入航班号:";
cin>>no;
break;
case 2:
cout<<"请输入终点站名称:";
cin>>name2;
break;
case 3:
cout<<"请输入起始站名称:";
cin>>name1;
cout<<"请输入终点站名称:";
cin>>name2;
break;
}
read();
for(i=0;i<m;i++)
{
if(strcmp(arr[i].over,name1)==0||strcmp(arr[i].over,name2)==0)
{
cout<<"\n查找航班信息成功!";
cout<<"航班号 起始站 终点站 时间 机票数\n";
cout<<PRINT;
break;
}
if(arr[i].num==no)
{
cout<<"\n查找航班信息成功!";
cout<<"航班号 起始站 终点站 时间 机票数\n";
cout<<PRINT;
break;
}
}
no=0;
cout<<"没有您需要的信息或查找完毕:";
cout<<"是否继续查找?请键入yes或no以回车键结束";
cin>>ii;
}while(strcmp(ii,"yes")==0);
}

void Hangkong::shanchu(){
char name1[20];
char name2[20];
char ii[10];
char f[]="2008china";
int no,n;
cout<<"请输入密码并以回车键结束:";
cin>>f;
if(strcmp(f,"2008china")==0)
{
do
{
cout<<"请选择删除以方式回车键结束:";
cout<<"*1.按航班号删除\n\n";
cout<<"*2.按航线删除\n\n";
cout<<"*0.返回\n\n";
cout<<"请在0-2中选择以回车键结束:";
cin>>n;
if(n==0)
break;
switch(n)
{
case 1:
cout<<"请输入航班号:";
cin>>no;
break;
case 2:
cout<<"请输入起始站 名称:";
cin>>name1;
cout<<"请输入终点站名称:";
cin>>name2;
break;
}
for(i=0;i<m;i++)
{
if(arr[i].num==no||strcmp(arr[i].start,name1)==0&&strcmp(arr[i].over,name2)==0)
{
arr[i]=arr[m-1];
m--;
}

}
cout<<"查找完毕或没有这个信息"<<endl;
cout<<"是否继续删除"<<endl;
cout<<"请键入yes或no以回车键结束"<<endl;
cin>>ii;
save();
if(!strcmp(ii,"yes"))
cout<<"请按任意键以回车键结束返回上层菜单:";
break;
}while(n!=1&&n!=2&&n!=3&&n!=4&&n!=0);
}
else
cout<<"对不起密码错误!您不是管理员,不能使用此项功能!谢谢!再见!";
}

void Hangkong::dingpiao(){
int n;
char a[10];
do
{
search();
cout<<"请输入您要订的机票数以回车键结束:";
cin>>n;
if(n<0)
{
cout<<"请输入有效的机票数!";
break;
}
if(arr[i].count!=0&&arr[i].count>=n)
{
arr[i].count=arr[i].count-n;
save();
cout<<"订票成功!";
break;
}
if(arr[i].count<n)
{
cout<<"请输入有效的机票数:";
break;
}
cout<<"是否继续? 请输入yes或no以回车键结束:";
cin>>a;
}while(!strcmp(a,"yes"));
}

void Hangkong::tuipiao(){
int n;
char a[10];
do
{
search();
cout<<"请输入您要退的机票数目:";
cin>>n;
if(n<0)
cout<<"请输入有效的机票数!";
arr[i].count=arr[i].count+n;
save();
cout<<"退票成功!";
cout<<"是否继续? 请键入yes或no以回车键结束:";
cin>>a;
}while(!strcmp(a,"yes"));
getchar();
}


void main()
{

int j;
Hangkong hang;

cout<<" ★---您好,欢迎进入中国民航管理系统!---★\n";
cout<<"================================================================================"<<endl;
do
{
cout<<" -------- ☆ 1.输入航班信息 ☆-------- ";
cout<<" -------- ☆ 2.浏览航班信息 ☆-------- ";
cout<<" -------- ☆ 3.修改航班信息 ☆-------- ";
cout<<" -------- ☆ 4.查找航班信息 ☆-------- ";
cout<<" -------- ☆ 5.删除航班信息 ☆-------- ";
cout<<" -------- ☆ 6.订票信息 ☆-------- ";
cout<<" -------- ☆ 7.退票信息 ☆-------- ";
cout<<" -------- ☆ 0.退出 ☆-------- ";
cout<<"================================================================================"<<endl;
cout<<"请在0-7中选择以回车键结束:";
cin>>j;
switch(j)
{
case 1: hang.input();
break;
case 2: hang.print();
break;
// case 3: hang.xiugai();
// break;
case 4: hang.search();
break;
case 5: hang.shanchu();
break;
case 6: hang.dingpiao();
break;
case 7: hang.tuipiao();
break;
case 0:
break;
}
}while(j!=0);
cout<<"谢谢使用,再见!"<<endl;
}



可以通过编译 内部的错误我就不知道了 ,你这个程序错误的地方很多


天行健,君子以自强不息!!QQ:68660681
2007-07-23 18:18
yy054201
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-7-23
收藏
得分:0 
回复:(maoguoqing)#include #inclu...
谢谢了。我就感觉这过程序内部各个函数的编写应该没什么问题,只是外部有问题,我将你改的输入了,还是不能运行啊!!!
2007-07-23 18:38
快速回复:[讨论]帮小弟改改程序吧,实在不知道怎么改了,谢谢啦!!
数据加载中...
 
   



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

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