您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 学生选课系统的设计
  所属分类: C/C++
  开发工具:
  文件大小: 850kb
  下载次数: 0
  上传时间: 2011-12-26
  提 供 者: suy***
 详细说明: #include #include #include #include #include using namespace std; class course; class student {public: student(){num=0;c=0;n=0;} string name; string number; int num; course *c; student *n; }; class course {public: course(){num=0;s=0;n=0;} string name; string code; int num; student *s; course *n; }; void main() { char *c1=new char [];course *che;student *she;string st1,st21,st22; while(true) { ifstream fi1("c.txt" ); if(fi1) {cout<<"读取文件中。。。\n"; fi1>>st1; if(st1.length()!=0) {string str1="MK2A"; course *p1=new course; che=p1; while(st1[0]!=0) {p1->name=st1; p1->code=str1; str1[3]++; p1->n=new course; p1=p1->n; fi1>>st1; } cout<<"文件读取成功!\n"; cout<<"代码\t\t\t\t课程\n"; p1=che; while(p1->n) {cout<code<<"\t\t\t\t"<name<<'\n'; p1=p1->n; } break; } else {cout<<"读取失败!!!请在根目录下建立"<<"c.txt"<<"文本文件并写入选课信息!\n";} } else {cout<<"ERROR:文件打开失败!!!!请在根目录下建立"<<"c.txt"<<"文本文件并写入选课信息!\n";} break;} system("cls"); while(true) { ifstream fi2("s.txt"); if(fi2) {cout<<"读取文件中。。。\n"; fi2>>st21>>st22; if(st21.length()!=0&&st22;.length()!=0) {string st20="12010rg"; student *p2=new student; she=p2; while(st21.length()!=0&&st22;.length()!=0) {st21=st20+st21; p2->number=st21; p2->name=st22; p2->n=new student; p2=p2->n; fi2>>st21>>st22; } cout<<"文件读取成功!\n"; cout<<"学生信息如下:\n"; cout<<"编号\t\t\t\t姓名\n"; p2=she; while(p2->n) {cout<number<<"\t\t\t"<name<<'\n'; p2=p2->n; } break; } else {cout<<"读取失败!!!请在根目录下建立"<<"s.txt"<<"文本文件并写入学生信息!\n";} } else {cout<<"ERROR:文件打开失败!!!!请在根目录下建立"<<"s.txt"<<"文本文件并写入学生信息!\n";} break;} system("cls"); char *c10="color 17",*c11="color 07"; system(c10); unsigned int i,j; for(i=0;i<=100;i++) { system("cls"); cout<<"\n\n\n\n\n\n\n\n\t\t\t---=欢迎进入冰之龙学生选课系统=---\n"; if(i!=100) { cout<<"\t\t\t\t程序载入中"; for(j=1;j<=i;j++) cout<<'.'; } cout<<"\n\n\n\n"; if(i!=100) { cout<<"\t\t\t\t "<>c1; if(c1[0]=='1') { while(true) { cout<<" _____________________________________________\n"; cout<<" | 1.修改课程信息 2.查看选课信息 |\n"; cout<<" | 3.按课程查看选课情况 4.按学生查看选课情况|\n"; cout<<" | 5.保存文件 0.退出 |\n"; cout<<" ---------------------------------------------\n"; cout<<"请选择你要的操作:";cin>>c1; if(c1[0]=='0')break; if(c1[0]<'0'||c1[0]>'5'){system("cls");cout<<"输入错误!请重新输入!!!\n";continue;} switch(c1[0]) { case '1': {system("cls"); cout<<"请选择是否修改课程信息(yes||no):"; while(true) {cin>>c1; if(c1[0]=='y'||c1[0]=='Y'||c1[0]=='N'||c1[0]=='n') {if(c1[0]=='y'||c1[0]=='Y') {cout<<"请选择1.修改 2.添加 3.删除 0.退出 :"; cin>>c1; while(true) {if(c1[0]=='0')break; switch(c1[0]) {case '1': {cout<<"请输入要修改的课程名称或代码:"; string str3;cin>>str3; course *cp=che;bool b1=false; while(cp->n!=0) {if(str3==cp->code||str3==cp->name) {b1=true;cout<<"请输入新的课程名称;"; cin>>cp->name;cout<<"修改成功!\n"; }cp=cp->n; } if(!b1)cout<<"没找到或输入错误!!!\n"; }break; case '2': {cout<<"请输入要添加的课程名称:"; string str3;cin>>str3; course *cp=che; while(cp->n!=0) { cp=cp->n;} cp->name=str3; cp->n=new course; cout<<"添加成功!\n"; }break; case '3': {cout<<"请输入要删除的课程名称或代码:"; string str3;cin>>str3; course *cp=che,*cp3;bool b1=false; while(cp->n!=0) {if(str3==cp->code||str3==cp->name) {b1=true; if(cp==che)che=che->n; else {cp3->n=cp->n;} cout<<"删除成功!\n";break; }cp3=cp;cp=cp->n; } if(!b1)cout<<"没找到或输入错误!!!\n"; }break; default:cout<<"输入错误!请重新输入!!!\n";break; } cout<<"请重新选择1.修改 2.添加 3.删除 0.退出 :"; cin>>c1; } break; } else {break;} } else {cout<<"输入错误!请重新输入!!!\n";cout<<"请选择是否修改课程信息(yes||no):";} } }break; case '2': { cout<<"选课信息如下:\n"; cout<<"代码\t\t\t\t课程\n"; course *p3=che; while(p3->n) {cout<code<<"\t\t\t\t"<name<<'\n'; p3=p3->n; } }break; case '3': {system("cls"); cout<<"选课情况如下:\n"; course *c6=che;student *s7;bool b10=1; while(c6->n) {if(c6->num) {b10=0;cout<code<<'\t'<name<<" 有"<num<<"名同学选,分别是:\n"; s7=c6->s; while(s7) {cout<number<<'\t'<name<<'\n';s7=s7->n;}} c6=c6->n;} if(b10){cout<<"还没开始选课 !!!\n";} }break; case '4': {system("cls"); cout<<"请选择1.查看某位学生选课信息 2.查看全部学生选课信息: "; while(true) {cin>>c1; if(c1[0]=='1'||c1[0]=='2') {if(c1[0]=='1') { cout<<"请输入参加选课学生的编号或姓名:"; string st8;cin>>st8;student *s8;bool b8; while(true) {s8=she;b8=false; while(s8->n) {if(s8->name==st8||s8->number==st8) {b8=true; if(s8->num==0){cout<<"该同学还没选课!!!\n";break;} else{cout<name<<" 同学选了"<num<<"门课程,分别是:\n"; course *c8;c8=s8->c; while(c8) {cout<code<<'\t'<name<<'\n';c8=c8->n;} break;} }s8=s8->n; } if(!b8)cout<<"没找到或输入错误!!!\n"; cout<<"请再次输入参加选课学生的编号或姓名(或按0结束查看):"; cin>>st8; if(st8[0]=='0')break; } break;} else { student *s8;bool b8; s8=she;b8=false; while(s8->n) { if(s8->num==0){s8=s8->n;continue;} else{b8=true;cout<name<<" 同学选了"<num<<"门课程,分别是:\n"; course *c8;c8=s8->c; while(c8) {cout<code<<'\t'<name<<'\n';c8=c8->n;} }s8=s8->n; } if(!b8){cout<<"同学们还没选课!!!\n";} break;} } else {cout<<"输入错误!请重新输入!!!\n";cout<<"请选择1.查看某位学生选课信息 2.查看全部学生选课信息: ";} } }break; case '5': {system("cls"); cout<<"\n\n\n\n\n\n\n\n\t\t保存文件中。。。\n"; FILE *fp5=fopen("选课情况.txt","w");fclose(fp5); ofstream fi15("选课情况.txt"); course *c65=che;student *s75;bool b15=1; while(c65->n) {if(c65->num) {b15=0;fi15<code<<'\t'<name<<" 有"<num<<"名同学选,分别是:\n"; s75=c65->s; while(s75) {fi15<number<<'\t'<name<<'\n';s75=s75->n;}} c65=c65->n;} if(b15){fi15<<"还没开始选课 !!!\n";} fi15.close(); system("cls"); cout<<"\n\n\n\n\n\n\n\n\t\t保存完成!!!\n"; system("选课情况.txt"); }break; } } system("cls");continue;} if(c1[0]=='2') { while(true) { cout<<" _______________________\n"; cout<<" | 1.查看选课信息 |\n"; cout<<" | 2.查看选课情况 |\n"; cout<<" | 3.开始选课 0.退出 |\n"; cout<<" -----------------------\n"; cout<<"请选择你要的操作:";cin>>c1; if(c1[0]=='0')break; if(c1[0]<'0'||c1[0]>'3'){system("cls");cout<<"输入错误!请重新输入!!!\n";continue;} switch(c1[0]) { case '1': {system("cls"); cout<<"选课信息如下:\n"; cout<<"代码\t\t\t\t课程\n"; course *p3=che; while(p3->n) {cout<code<<"\t\t\t\t"<name<<'\n'; p3=p3->n; } }break; case '2': {system("cls"); cout<<"请输入参加选课学生的编号或姓名:"; string st8;cin>>st8;student *s8;bool b8; while(true) {s8=she;b8=false; while(s8->n) {if(s8->name==st8||s8->number==st8) {b8=true; if(s8->num==0){cout<<"该同学还没选课!!!\n";break;} else{cout<name<<" 同学选了"<num<<"门课程,分别是:\n"; course *c8;c8=s8->c; while(c8) {cout<code<<'\t'<name<<'\n';c8=c8->n;} break;} }s8=s8->n; } if(!b8)cout<<"没找到或输入错误!!!\n"; cout<<"请再次输入参加选课学生的编号或姓名(或按0结束查看):"; cin>>st8; if(st8[0]=='0')break; } }break; case '3': {system("cls"); cout<<"开始选课。。。。。。。。。。。。。\n"; cout<<"选课信息如下:\n"; cout<<"代码\t\t\t\t课程\n"; course *p3=che; while(p3->n) {cout<code<<"\t\t\t\t"<name<<'\n'; p3=p3->n; } cout<<"请输入参加选课学生的编号或姓名:"; string st5,cstr5;cin>>st5; student *s5,*sp5;course *c5,*cp5;bool b2,b3; while(true) {s5=she;b2=false; while(s5->n) {if(s5->name==st5||s5->number==st5) { b2=true; cout<name<<"同学,你好!\t请输入你选的课程的代码:"; cin>>cstr5; while(true) {c5=che;b3=false; while(c5->n) {if(c5->code==cstr5) {b3=true; if(s5->c!=0) {course *c5p5=s5->c;bool b4=false; while(c5p5) {if(c5p5->code==cstr5){b4=true;break;}c5p5=c5p5->n;} if(b4){cout<name<<"同学,该课你已经选择了!!! 请重新选择。。。。\n";break;}} if(s5->c==0) {s5->c=new course;s5->num++; s5->c->name=c5->name;s5->c->code=c5->code;} else {cp5=new course;s5->num++;cp5->n=s5->c; cp5->name=c5->name;cp5->code=c5->code; s5->c=cp5;} if(c5->s==0) {c5->s=new student;c5->num++; c5->s->name=s5->name;c5->s->number=s5->number;} else {sp5=new student;c5->num++;sp5->n=c5->s; sp5->name=s5->name;sp5->number=s5->number; c5->s=sp5;} cout<name<<"同学,选课成功!!!\n"; cout<name<<"同学,选了"<code<<'\t'<name<<'\n'; break; }c5=c5->n; } if(!b3)cout<<"没找到或输入错误!!!\n"; cout<<"请再次输入你选的课程的代码(或按0结束选课):"; cin>>cstr5; if(cstr5[0]=='0')break; } break; } s5=s5->n; } if(!b2)cout<<"没找到或输入错误!!!\n"; cout<<"请再次输入参加选课学生的编号或姓名(或按0结束选课):"; cin>>st5; if(st5[0]=='0')break; } }break; } } system("cls");continue;} if(c1[0]=='0'){break;} cout<<"输入错误!请重新输入!!!\n"; } system("cls"); cout<<"\n\n\n\n\n\n\n\n\t\t保存文件中。。。\n"; FILE *fp5=fopen("选课情况.txt","w");fclose(fp5); ofstream fi15("选课情况.txt"); course *c65=che;student *s75;bool b15=1; while(c65->n) {if(c65->num) {b15=0;fi15<code<<'\t'<name<<" 有"<num<<"名同学选,分别是:\n"; s75=c65->s; while(s75) {fi15<number<<'\t'<name<<'\n';s75=s75->n;}} c65=c65->n;} if(b15){fi15<<"还没开始选课 !!!\n";} fi15.close(); system("cls"); cout<<"\n\n\n\n\n\n\n\n\t\t保存完成!!!\n"; system("选课情况.txt"); ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: 选课系统
 输入关键字,在本站1000多万海量源码库中尽情搜索: