大二c++大作业,百度了代码老是不能运行,求大神们给我改改,能运行就行。

Setcpl 2015-01-14 09:11:47
define.h
class Date //定义日期类以便记录考试时间及课程时间
{
int year; //年份
int month; //月份
int day; //天
int hourStart; //开始时间
int hourEnd; //结束时间
public:
void setDate(int Year,int Month,int Day,int HourStart,int HourEnd); //对类进行赋值
void showDate();
void operator =(Date);
};
class Student //定义学生类以记录学会的基本信息
{
char name[17]; //姓名
char sex; //性别
char identy[19]; //身份证号
int age; //年龄
public:
char* getIdenty(){return identy;}
void setStudent(char*Name,char Sex,int Age,char*Identy);
void modifyStudent(char*Name,char Sex,int Age,char*Identy); //修改学生基本信息
void showStudent(); //显示学生基本信息
};
class Arrange:public Date //定义安排类以安排考试或是课程等信息
{
Date lesson[6]; //定义课程类数组以记录多个课程时间信息
Date exam[5];//定义考试类数组以记录多个考试时间信息
int lessonNum; //定义lessonNum 以记录课程的数目
int examNum; //定义examNum 以记录考试的数目
public:
int getLessonNum(){return lessonNum;} //获得课程安排的数目
int getExamNum(){return examNum;} //获得考试安排的数目
void setLessonNum(int LessonNum) //设置课程数目
{
lessonNum=LessonNum;
}
void setExamNum(int ExamNum)//设置考试数目
{
examNum=ExamNum;
}
void lessonArrange(); //课程安排函数,安排课程时间段
void showLessonArr(); //显示课程安排函数,显示安排的课程
void examArrange(); //考试安排函数,安排考试时间段
void showExamArr(); //显示考试安排函数,显示安排的考试
void cancelArrange(); //取消安排函数,取消安排的考试或课程
void changeArrange(); //更改安排函数,更改已安排的考试或是课程
};
class studentInfor //定义驾校学生类
{
float charge; //费用
Arrange stu1;
Student student;
public:
void setCharge(float Charge) //设置收费情况
{
charge=Charge;
}
void showArrange(); //显示所有安排
void setStuInfor(); //设置学生信息
void showStuInfor(); //显示学生所有信息
char* getStuIdenty() //获得学生身份证号
{
char*p;
p=student.getIdenty();
return p;
}
float getCharge(){return charge;} //获得收费函数
void modifyStuInfor(); //修改学生信息函数
void cancel(); //取消函数
};


...全文
703 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
柳11 2015-02-12
  • 打赏
  • 举报
回复
唉,,,真是蛋疼!
jacksonfan 2015-01-18
  • 打赏
  • 举报
回复
引用 6 楼 Setcpl 的回复:
能不能帮我改改给我能运行的啊,真的很急啊,自己看不懂。
问题都给你找出来了,再要是搞不定就放弃吧 这玩意儿不适合你玩
dengdayuge 2015-01-18
  • 打赏
  • 举报
回复
lol..砖二大神带带你..
勤奋的小游侠 2015-01-16
  • 打赏
  • 举报
回复
这学期你都干嘛去了?
Setcpl 2015-01-15
  • 打赏
  • 举报
回复
能不能帮我改改给我能运行的啊,真的很急啊,自己看不懂。
纹枰老妖 2015-01-15
  • 打赏
  • 举报
回复
define.h 
class Date      //定义日期类以便记录考试时间及课程时间
{
int year;    //年份
int month;   //月份 
int day;     //天
int hourStart;    //开始时间
int hourEnd;     //结束时间
public:
void setDate(int Year,int Month,int Day,int HourStart,int HourEnd); //对类进行赋值
void showDate();
void operator =(Date);
};
class Student    //定义学生类以记录学会的基本信息
{
char name[17];   //姓名
char sex;        //性别
char identy[19];    //身份证号
int age;      //年龄
public:
char* getIdenty(){return identy;}
void setStudent(char*Name,char Sex,int Age,char*Identy);
void modifyStudent(char*Name,char Sex,int Age,char*Identy);    //修改学生基本信息 
void showStudent();    //显示学生基本信息
};
class Arrange:public Date    //定义安排类以安排考试或是课程等信息
{    
Date lesson[6];    //定义课程类数组以记录多个课程时间信息
Date exam[5];//定义考试类数组以记录多个考试时间信息
int lessonNum; //定义lessonNum 以记录课程的数目
int examNum;  //定义examNum 以记录考试的数目
public:
int getLessonNum(){return lessonNum;}  //获得课程安排的数目
int getExamNum(){return examNum;} //获得考试安排的数目
void setLessonNum(int LessonNum)  //设置课程数目
{
lessonNum=LessonNum;
}
void setExamNum(int ExamNum)//设置考试数目
{
examNum=ExamNum;
}
void lessonArrange();      //课程安排函数,安排课程时间段
void showLessonArr();     //显示课程安排函数,显示安排的课程
void examArrange();      //考试安排函数,安排考试时间段
void showExamArr();     //显示考试安排函数,显示安排的考试
void cancelArrange();   //取消安排函数,取消安排的考试或课程
void changeArrange();   //更改安排函数,更改已安排的考试或是课程
};
class studentInfor   //定义驾校学生类
{
float charge;      //费用
Arrange stu1;
Student student;
public:
void setCharge(float Charge)  //设置收费情况
{
charge=Charge;
}
void showArrange(); //显示所有安排
void setStuInfor(); //设置学生信息
void showStuInfor(); //显示学生所有信息
char* getStuIdenty() //获得学生身份证号
{
char*p;
p=student.getIdenty();
return p;
}
float getCharge(){return charge;} //获得收费函数
void modifyStuInfor();  //修改学生信息函数
void cancel(); //取消函数
};

li4c 2015-01-15
  • 打赏
  • 举报
回复
祝你 考59分
jacksonfan 2015-01-14
  • 打赏
  • 举报
回复
1、setStuInfor()没有实现代码 2、cout<<"**开始时间: ";cin>>HourStart1;cout<<" 结束时间: ";cin>>HourEnd1; 类似这种字串换行的错误
Setcpl 2015-01-14
  • 打赏
  • 举报
回复
void studentInfor::showStuInfor() //显示学生信息及其安排 { student.showStudent(); cout<<"费用: "<<getCharge()<<endl; stu1.showExamArr(); stu1.showLessonArr(); } void studentInfor::showArrange() { cout<<"***************安排***************"<<endl; stu1.showExamArr(); stu1.showLessonArr(); } void studentInfor::modifyStuInfor() //修改安排或是学生信息 { int choice; cout<<"请选择你想要修改的内容 : "<<endl; cout<<"******0: 修改学生基本信息 ;"<<endl; cout<<"******1: 修改课程或考试安排 ;"<<endl; cout<<"*********************************************"<<endl; cout<<"请选择 : ";cin>>choice; switch(choice) { case 0: { char Name[15];char Identy[19];char Sex='0';int Age=0; student.showStudent(); cout<<"输入想要修改的内容 :"<<endl; cout<<"名字: ";cin>>Name;cout<<"性别: ";cin>>Sex;cout<<" 年龄: ";cin>>Age; cout<<"身份证号: ";cin>>Identy; student.modifyStudent(Name,Sex,Age,Identy); break; } case 1: { stu1.changeArrange(); break; } default: { cout<<"错误!"; break; } } } void studentInfor::cancel() //取消学生安排 { stu1.cancelArrange(); } menu.cpp #include"method.h" #include<fstream.h> #include<stdlib.h> studentInfor person; void inputInfor() { ofstream ofile("stuInfor.dat",ios::out|ios::app|ios::binary); if(!ofile) { cout<<"打开文件失败 !"; } person.setStuInfor(); ofile.write((char*)&person,sizeof(person)); ofile.close(); } void main() { int decide;char p='N'; do{ system("cls"); cout<<" "<<"********************************************"<<endl; cout<<" "<<"************欢迎进入驾校报考系统************"<<endl; cout<<" "<<"********** 0: 学生通道 ***************"<<endl; cout<<" "<<"********** 1: 负责人通道 ***********"<<endl; cout<<" "<<"********** 2: 退出 **********"<<endl; cout<<" "<<"********************************************"<<endl; cout<<"请选择: ";cin>>decide; switch(decide) { case 0: { int n1; char p1='N'; do{ system("cls"); cout<<" "<<"*********** 学生通道 *************"<<endl; cout<<" "<<"*********** 0: 查找 **********"<<endl; cout<<" "<<"*********** 1: 修改 **********"<<endl; cout<<" "<<"*********** 2: 删除 ***********"<<endl; cout<<" "<<"************************************"<<endl; cout<<"请选择 : "; cin>>n1; switch(n1) { case 0: { char Identy[19]; cout<<"请输入你想要查找的学生的身份证号: ";cin>>Identy; ifstream ifile("stuInfor.dat",ios::in|ios::binary); if (!ifile ) cout<<"文件打开失败"<<endl; while(!ifile.eof()) { ifile.read((char*)&person,sizeof(person)); if(!(strcmp(Identy,person.getStuIdenty()))) { person.showStuInfor(); break; } } if(!ifile) cout<<"查找失败"<<endl; ifile.close(); break; } case 1: { char Identy[19];int count=0; cout<<" 请输入你想要修改的学生的身份证号: ";cin>>Identy; ifstream ifile("stuInfor.dat",ios::in|ios::binary); if (!ifile ) cout<<"文件打开失败"<<endl; while(!ifile.eof()) { ifile.read((char*)&person,sizeof(person)); count++; if(!(strcmp(Identy,person.getStuIdenty()))) { ifile.close(); ofstream ofile("stuInfor.dat",ios::out|ios::in|ios::binary); ofile.seekp((count-1)*sizeof(person),ios::cur); person.modifyStuInfor(); ofile.write((char*)&person,sizeof(person)); ofile.close(); break; } } if(!ifile) cout<<"没有你要的记录"<<endl; ifile.close(); break; } case 2: { char Identy[19];int count=0; cout<<" 请输入你想要删除的学生的身份证号 ";cin>>Identy; ifstream ifile("stuInfor.dat",ios::in|ios::binary); if (!ifile ) cout<<"文件打开失败"<<endl; while(!ifile.eof()) { ifile.read((char*)&person,sizeof(person)); count++; if(!strcmp(Identy,person.getStuIdenty())) { ifile.close(); ofstream ofile("stuInfor.dat",ios::out|ios::in|ios::binary); ofile.seekp((count-1)*sizeof(person),ios::cur); person.cancel(); ofile.write((char*)&person,sizeof(person)); ofile.close(); break; } } if(!ifile) cout<<"没有你要的记录"<<endl; ifile.close(); break; } default: { cout<<"错误!"; break; } } cout<<"是否在学生通道上继续操作 ? "; cin>>p1; }while(p1=='Y'||p1=='y'); break; } case 1: { int n2;char p2='N'; do{ system("cls"); cout<<" "<<"************* 负责人通道 **************"<<endl; cout<<" "<<"******** 0: 输入信息 *********"<<endl; cout<<" "<<"******** 1: 查找 ***"<<endl; cout<<" "<<"******** 2: 修改 ***"<<endl; cout<<" "<<"******** 3: 删除 ***"<<endl; cout<<" "<<"***************************************"<<endl; cout<<"请选择: ";cin>>n2; switch(n2) { case 0: { inputInfor(); cout<<"*************************************************"<<endl; break; } case 1: { char Identy[19]; cout<<"请输入你想要查找的学生的身份证号: ";cin>>Identy; ifstream ifile("stuInfor.dat",ios::in|ios::binary); if (!ifile ) cout<<"文件打开失败"<<endl; while(!ifile.eof()) { ifile.read((char*)&person,sizeof(person)); if(!(strcmp(Identy,person.getStuIdenty()))) { person.showStuInfor(); break; } } if(!ifile) cout<<"查找失败"<<endl; ifile.close(); break; } case 2: { char Identy[19];int count=0; cout<<"请输入你想要修改的学生的身份证号:";cin>>Identy; ifstream ifile("stuInfor.dat",ios::in|ios::binary); if (!ifile ) cout<<"文件打开失败"<<endl; while(!ifile.eof()) { ifile.read((char*)&person,sizeof(person)); count++; if(!(strcmp(Identy,person.getStuIdenty()))) { ifile.close(); ofstream ofile("stuInfor.dat",ios::out|ios::in|ios::binary); ofile.seekp((count-1)*sizeof(person),ios::cur); person.modifyStuInfor(); ofile.write((char*)&person,sizeof(person)); ofile.close(); break; } } if(!ifile) cout<<"没有你要的记录"<<endl; ifile.close(); break; } case 3: { char Identy[19];int count=0; cout<<"请输入你想要删除的学生的身份证号 ";cin>>Identy; ifstream ifile("stuInfor.dat",ios::in|ios::binary); if (!ifile ) cout<<"文件打开失败"<<endl; while(!ifile.eof()) { ifile.read((char*)&person,sizeof(person)); count++; if(!strcmp(Identy,person.getStuIdenty())) { ifile.close(); ofstream ofile("stuInfor.dat",ios::out|ios::in|ios::binary); ofile.seekp((count-1)*sizeof(person),ios::cur); person.cancel(); ofile.write((char*)&person,sizeof(person)); ofile.close(); break; } } if(!ifile) cout<<"没有你要的记录"<<endl; ifile.close(); break; } default: { cout<<"错误!"; break; } } cout<<"是否在负责人通道继续操作 ? "; cin>>p2; }while(p2=='Y'||p2=='y'); break; } case 2: { break; } } cout<<"************是否返回到系统 ? "; cin>>p; }while(p=='Y'||p=='y'); }
Setcpl 2015-01-14
  • 打赏
  • 举报
回复
method.h #include<iostream.h> #include<string.h> #include"define.h" /*对Date类中的方法的实现*/ void Date::setDate(int Year,int Month,int Day,int HourStart,int HourEnd) { year=Year; month=Month; day=Day; hourStart=HourStart; hourEnd=HourEnd; } void Date::operator =(Date d1) { year=d1.year; month=d1.month; day=d1.day; hourStart=d1.hourStart; hourEnd=d1.hourEnd; } void Date::showDate() { cout<<"年: "<<year<<" 月: "<<month<<" 日: "<<day<<endl; cout<<"开始时间: "<<hourStart<<" 结束时间: "<<hourEnd<<endl; if(hourStart==hourEnd==year==month==day==0) cout<<"此时间段已被取 消"<<endl; } /*对Student类中的方法的实现*/ void Student::setStudent(char*Name,char Sex,int Age,char*Identy) {strcpy(name,Name); sex=Sex; strcpy(identy,Identy); age=Age; } void Student::modifyStudent(char*Name,char Sex,int Age,char*Identy) {strcpy(name,Name); sex=Sex; strcpy(identy,Identy); age=Age; } void Student::showStudent() { cout<<"******************* 学生信息 ********************"<<endl; cout<<"姓名: "<<name<<" "<<"性别: "<<sex<<" "<<"年龄: "<<age<<endl; cout<<"身份证号: "<<identy<<endl; } /*对Arrange类中的方法的实现*/ void Arrange::lessonArrange() //安排课程 { int i,lessNum,Month=0,Day=0,Year=0,HourStart=0,HourEnd=0; cout<<"请输入课程数目 : "; cin>>lessNum; setLessonNum(lessNum); for(i=0;i<lessNum;i++) { cout<<"*******课程 "<<i<<"*********"<<endl; cout<<"**年: ";cin>>Year;cout<<" 月: ";cin>>Month;cout<<" 日: ";cin>>Day; cout<<"**开始时间: ";cin>>HourStart;cout<<" 结束时间: ";cin>>HourEnd; lesson[i].setDate(Year,Month,Day,HourStart,HourEnd); } } void Arrange::showLessonArr() //显示课程安排 { int i; cout<<"************************* 课程信息 **********************"<<endl; if(getLessonNum()==0) cout<<"没有安排课程 !"<<endl; else{ for(i=0;i<getLessonNum();i++) { cout<<"********课程 "<<i<<" ********"<<endl; lesson[i].showDate(); cout<<"**********************************"<<endl; } } } void Arrange::examArrange() //安排考试 { int i,testNum,Month=0,Day=0,Year=0,HourStart=0,HourEnd=0; cout<<"请输入考试的数目 : "; cin>>testNum; setExamNum(testNum); for(i=0;i<testNum;i++) { cout<<"*******考试 "<<i<<"*********"<<endl; cout<<"**年: ";cin>>Year;cout<<" 月: ";cin>>Month;cout<<" 日: ";cin>>Day; cout<<"**开始时间: ";cin>>HourStart;cout<<" 结束时间: ";cin>>HourEnd; exam[i].setDate(Year,Month,Day,HourStart,HourEnd); cout<<"******************************"<<endl; } } void Arrange::showExamArr() //显示考试安排 { int i; cout<<"*************************** 考试信息 **********************"<<endl; if(getExamNum()==0) cout<<"没有安排考试!"<<endl; else{ for(i=0;i<getExamNum();i++) { cout<<"********* 考试 "<<i<<" ***********"<<endl; exam[i].showDate(); cout<<"***********************************************************"<<endl; } } } void Arrange::cancelArrange() { int choose,n; cout<<"**取消考试或是课程 ? 请选择 : (0代表课程 ; 1代表考试 )"; cin>>choose; switch(choose) { case 0: { showLessonArr(); if(getLessonNum()==0) cout<<"没有安排课程,无法取消"<<endl; else{ cout<<"请选择取消哪一门课程 (从 0 to "<<(getLessonNum()-1)<<" )"<<endl; cout<<"选择: "; cin>>n; lesson[n].setDate(0,0,0,0,0); } break; } case 1: { showExamArr(); if(getExamNum()==0) cout<<"没有安排考试,无法取消"<<endl; else{ cout<<"请选择取消哪一场考试 (从 0 到 "<<(getExamNum()-1)<<" ) "<<endl; cout<<"选择: "; cin>>n; exam[n].setDate(0,0,0,0,0); } break; } default: { cout<<"错误!"; break; } } } void Arrange::changeArrange() //修改安排 { int choose1,n,Year1=0,Month1=0,Day1=0,HourStart1=0,HourEnd1=0; cout<<"**修改课程或是考试 ? 请选择 : (0 代表课程 ; 1 代表考试)"; cin>>choose1; switch(choose1) { case 0: { showLessonArr(); if(getLessonNum()==0) cout<<"没有安排课程,无法修改"<<endl; else{ cout<<"请选择修改哪一门课程 (从 0 到 "<<(getLessonNum()-1)<<" )"<<endl; cout<<"选择: "; cin>>n; cout<<"开始输入: "<<endl; cout<<"**年: ";cin>>Year1;cout<<" 月: ";cin>>Month1;cout<<" 日: ";cin>>Day1; cout<<"**开始时间: ";cin>>HourStart1;cout<<" 结束时间: ";cin>>HourEnd1; lesson[n].setDate(Year1,Month1,Day1,HourStart1,HourEnd1); } break; } case 1: { showExamArr(); if(getExamNum()==0) cout<<"没有安排考试,无法修改"<<endl; else{ cout<<"请选择修改哪一场考试 (从 0 to "<<(getExamNum()-1)<<" )"<<endl; cout<<"选择: "; cin>>n; cout<<"开始输入: "<<endl; cout<<"**年: ";cin>>Year1;cout<<" 月: ";cin>>Month1;cout<<" 天: ";cin>>Day1; cout<<"**开始时间: ";cin>>HourStart1;cout<<" 结束时间: ";cin>>HourEnd1; exam[n].setDate(Year1,Month1,Day1,HourStart1,HourEnd1); } break; } default: { cout<<"错误!"; break; } } }

64,635

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧