欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    高校自动排课系统(共11页).docx

    • 资源ID:14333534       资源大小:17.82KB        全文页数:11页
    • 资源格式: DOCX        下载积分:20金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要20金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    高校自动排课系统(共11页).docx

    精选优质文档-倾情为你奉上/简化版高校自动排课系统/排课任务简化后包含:年级专业(教学班级,如计科13)、课程名称、任课教师、上课地点和时间/教学班级简化为不分人数,不分专业方向。/上课教室简化为不分理论课、实验课,不分教室容纳人数,不分是否多媒体。/上课时段简化为:一周五天,周一到周五,白天上课,上午四节,下午四节,/12(8:009:400)、34(10:0011:40)、56(14:0015:40)、78(16:0017:40)/为了便于处理,将五天的所有上课时段用数字019表示/上课地点和时间组合成一个整数数组(位集,bitset),每20个为1组为一个教室的上课时段安排/约束条件:1、教学班级的上课时间不能冲突/2、每个教室不能同时安排多个教学班级上课/3、任课教师的上课时间不能冲突/#include <iostream>#include <fstream>#include <sstream>#include <string>#include <vector>#include <bitset>#include <random>#include <iomanip>using namespace std;/原始数据文件中的每一行数据的数据结构struct schedule string grade_special; /年级专业string course; /课程名称string teacher; /任课教师string total_hour; /总学时string teach_hour; /讲课学时string experiment_hour; /实验学时string practice_hour; /课程实践学时string credit; /学分string week_hour; /周学时string start_stop; /起止周string speciality_orientation; /专业方向string person_num; /人数;/排课任务的数据结构struct arrange arrange(string gs, string c, string t, int ct = -1) : grade_special(gs), course(c), teacher(t), classroom_time(ct) string grade_special;/年级专业string course;/课程名称string teacher;/任课教师/string classroom;/上课地点/string time;/上课时间int classroom_time;/上课地点、时间;/教师倒排表数据结构,通过教师姓名找到该教师的排课情况struct teacher_inverted teacher_inverted(string tea, int cl = -1, int ar = -1) : teacher(tea), class_loc(cl), arrange_loc(ar) string teacher;int class_loc;int arrange_loc;/教室倒排表数据结构,通过教室名称查找该教室的排课情况struct classroom_inverted classroom_inverted(string cr, int cl = -1, int ar = -1) : classroom(cr), class_loc(cl), arrange_loc(ar) string classroom;int class_loc;int arrange_loc;int main(int argc, char* argv) if (argc != 3) cout << "程序调用格式错误!n调用格式:csp 排课计划文件 可用教室文件n"return 0;ifstream infile(argv1);vector<schedule> plan;string s;getline(infile, s);while (getline(infile, s) schedule sch;istringstream record(s);record >> sch.grade_special >> sch.course >> sch.teacher >> sch.total_hour >> sch.teach_hour>> sch.experiment_hour >> sch.practice_hour >> sch.credit >> sch.week_hour >> sch.start_stop>> sch.speciality_orientation >> sch.person_num;plan.push_back(sch);infile.close();vector<vector<arrange>> arranges; /整个系的排课安排vector<arrange> arr; /一个班的排课安排string gs(""); /教学班级for (auto it = plan.begin(); it != plan.end(); +it) if (gs != it->grade_special) if (!arr.empty() arranges.push_back(arr); /教学计划按教学班级顺序排列arr.clear();gs = it->grade_special;arr.push_back(arrange(it->grade_special, it->course, it->teacher);arranges.push_back(arr);vector<vector<teacher_inverted>> teachers; /教师数组for (unsigned i = 0; i < arranges.size(); +i) for (unsigned j = 0; j < arrangesi.size(); +j) string tea = arrangesij.teacher;if (tea = "未定") continue;unsigned k = 0;for (; k < teachers.size(); +k) if (teachersk0.teacher = tea) teachersk.push_back(teacher_inverted(tea, i, j);break;if (k = teachers.size() vector<teacher_inverted> ti; /一个教师的排课信息倒排表ti.push_back(teacher_inverted(tea, i, j);teachers.push_back(ti);const int N = 256;bitset<N> ct; /教室时段的分配状况infile.open(argv2);vector<string> classrooms;/教室数组while (getline(infile, s) classrooms.push_back(s);infile.close();unsigned arrange_num = plan.size(); /待排课数目unsigned class_num = arranges.size(); /教学班级数目unsigned classroom_num = classrooms.size(); /教室数目uniform_int_distribution<unsigned> u(0, classroom_num * 20 - 1); /为教室时段分配随机数default_random_engine e(time(0);vector<unsigned> class_loc(class_num, 0); /教学班级已分配状况unsigned class_cur = 0; /待分配的教学班级序号,轮流为每个班级排课,一次安排一个班的一门课for (unsigned n = 0; n < arrange_num; +n) unsigned k = u(e);/如果某个班级的排课任务已经分配完成,则选择下一个班级继续排课while (class_locclass_cur = arrangesclass_cur.size() class_cur = (class_cur + 1) % class_num;/找到待排课任务的对应教师string tea = arrangesclass_curclass_locclass_cur.teacher;unsigned i = 0;for (; i < teachers.size(); +i) if (tea = teachersi0.teacher) break;/找出与该教师无时间冲突的时段do do while (ct.test(k) k = (k + 1) % (classroom_num * 20); unsigned m = 0;for (; m < class_locclass_cur; +m) if (arrangesclass_curm.classroom_time % 20 = k % 20) break;if (m = class_locclass_cur) break; /如果与前面已安排的该班级时间无冲突,则k可用k = (k + 1) % (classroom_num * 20); /如果有冲突则检查下一个教室时段是否可用 while (1);if (i = teachers.size() break; /教师未定unsigned j = 0;for (; j < teachersi.size(); +j) int m = arrangesteachersij.class_locteachersij.arrange_loc.classroom_time;if (m != -1 && (m % 20 = k % 20) break;if (j = teachersi.size() break; /如果与该教师的时间无冲突,则k可用k = (k + 1) % (classroom_num * 20); /如果有冲突则检查下一个教室时段是否可用 while (1);/排课arrangesclass_curclass_locclass_cur.classroom_time = k;ct.set(k);/将当前班级的排课号+1+class_locclass_cur;/将待排课班级号+1class_cur = (class_cur + 1) % class_num;loop: /输出cout << "tt高校自动排课系统n"cout << "选择查询条件:1. 按班级 2. 按教师 3. 按教室n"cout << "请输入查询序号:(输入-1退出系统)"unsigned choice = 0;cin >> choice;if (-1 = choice) cout << "正常退出系统n"return 0;else if (1 = choice) unsigned i = 0, j = 0;for (; i < arranges.size(); +i) cout << i << ". " << arrangesi0.grade_special << "t"if (i + 1) % 4 = 0) cout << "n"cout << "n"do cout << "n请输入待查询班级的序号:(输入-1结束查询)"cin >> i;if (i = -1) break;else if (i >= arranges.size() cout << "非法选择n"continue;int class_table45;for (unsigned m = 0; m < 4; +m)for (unsigned n = 0; n < 5; +n)class_tablemn = -1;for (j = 0; j < arrangesi.size(); +j) unsigned m = arrangesij.classroom_time % 20;class_tablem / 5m % 5 = j;string time_slot4 = "8:00-9:40", "10:00-11:40", "14:00-15:40", "16:00-17:40" ;cout << setiosflags(ios_base:left);cout << setw(54) << " " << arrangesi0.grade_special << "班级课程表n"cout << "=n"cout << setw(12) << " " << setw(24) << "星期一" << setw(24) << "星期二" << setw(24) << "星期三" << setw(24) << "星期四" << setw(24) << "星期五" << "n"for (unsigned m = 0; m < 4; +m) if (m % 2 = 0)cout << "=n"elsecout << "-n"for (unsigned m1 = 0; m1 < 3; +m1) if (m1 = 1)cout << setw(12) << time_slotm;elsecout << setw(12) << ""for (unsigned n = 0; n < 5; +n) if (class_tablemn != -1) j = class_tablemn;if (m1 = 0)cout << setw(24) << arrangesij.course;else if (m1 = 1)cout << setw(24) << classroomsarrangesij.classroom_time / 20;elsecout << setw(24) << arrangesij.teacher;elsecout << setw(24) << " "cout << "n"cout << "=n"cout << resetiosflags(ios_base:left); while (1);else if (2 = choice) unsigned i = 0, j = 0;for (; i < teachers.size(); +i) cout << i << ". " << teachersi0.teacher << "t"if (i + 1) % 4 = 0) cout << "n"cout << "n"do cout << "n请输入待查询教师的序号:(输入-1结束查询)"cin >> i;if (i = -1) break;else if (i >= teachers.size() cout << "非法选择n"continue;int class_table45;for (unsigned m = 0; m < 4; +m)for (unsigned n = 0; n < 5; +n)class_tablemn = -1;for (j = 0; j < teachersi.size(); +j) unsigned m = arrangesteachersij.class_locteachersij.arrange_loc.classroom_time / 20;class_tablem / 5m % 5 = j;string time_slot4 = "8:00-9:40", "10:00-11:40", "14:00-15:40", "16:00-17:40" ;cout << setiosflags(ios_base:left);cout << setw(54) << " " << teachersi0.teacher << "老师课程表n"cout << "=n"cout << setw(12) << " " << setw(24) << "星期一" << setw(24) << "星期二" << setw(24) << "星期三" << setw(24) << "星期四" << setw(24) << "星期五" << "n"for (unsigned m = 0; m < 4; +m) if (m % 2 = 0)cout << "=n"elsecout << "-n"for (unsigned m1 = 0; m1 < 3; +m1) if (m1 = 1)cout << setw(12) << time_slotm;elsecout << setw(12) << ""for (unsigned n = 0; n < 5; +n) if (class_tablemn != -1) j = class_tablemn;if (m1 = 0)cout << setw(24) << arrangesteachersij.class_locteachersij.arrange_loc.course;else if (m1 = 1)cout << setw(24) << classroomsarrangesteachersij.class_locteachersij.arrange_loc.classroom_time / 20;elsecout << setw(24) << arrangesteachersij.class_locteachersij.arrange_loc.grade_special;elsecout << setw(24) << " "cout << "n"cout << "=n"cout << resetiosflags(ios_base:left); while (1); else if (3 = choice) vector<vector<classroom_inverted>> classroomes;for (unsigned i = 0; i < classrooms.size(); +i) classroom_inverted cr(classroomsi);vector<classroom_inverted> crs;crs.push_back(cr);classroomes.push_back(crs);unsigned i = 0, j = 0;for (i = 0; i < arranges.size(); +i) for (j = 0; j < arrangesi.size(); +j) unsigned m = arrangesij.classroom_time;if (classroomesm / 200.class_loc = -1) classroomesm / 200.class_loc = i;classroomesm / 200.arrange_loc = j;else classroomesm / 20.push_back(classroom_inverted(classroomesm / 200.classroom, i, j);for (i = 0; i < classrooms.size(); +i) cout << i << ". " << classroomsi << "t"if (i + 1) % 4 = 0) cout << "n"cout << "n"do cout << "n请输入待查询教室的序号:(输入-1结束查询)"cin >> i;if (i = -1) break;else if (i >= classrooms.size() cout << "非法选择n"continue;int class_table45;for (unsigned m = 0; m < 4; +m)for (unsigned n = 0; n < 5; +n)class_tablemn = -1;for (j = 0; j < classroomesi.size(); +j) unsigned m = arrangesclassroomesij.class_locclassroomesij.arrange_loc.classroom_time % 20;class_tablem / 5m % 5 = j;string time_slot4 = "8:00-9:40", "10:00-11:40", "14:00-15:40", "16:00-17:40" ;cout << setiosflags(ios_base:left);cout << setw(54) << " " << classroomsi << "教室课程表n"cout << "=n"cout << setw(12) << " " << setw(24) << "星期一" << setw(24) << "星期二" << setw(24) << "星期三" << setw(24) << "星期四" << setw(24) << "星期五" << "n"for (unsigned m = 0; m < 4; +m) if (m % 2 = 0)cout << "=n"elsecout << "-n"for (unsigned m1 = 0; m1 < 3; +m1) if (m1 = 1)cout << setw(12) << time_slotm;elsecout << setw(12) << ""for (unsigned n = 0; n < 5; +n) if (class_tablemn != -1) j = class_tablemn;if (m1 = 0)cout << setw(24) << arrangesclassroomesij.class_locclassroomesij.arrange_loc.course;else if (m1 = 1)cout << setw(24) << arrangesclassroomesij.class_locclassroomesij.arrange_loc.teacher;elsecout << setw(24) << arrangesclassroomesij.class_locclassroomesij.arrange_loc.grade_special;elsecout << setw(24) << " "cout << "n"cout << "=n"cout << resetiosflags(ios_base:left); while (1);else cout << "非法选择n"goto loop;专心-专注-专业

    注意事项

    本文(高校自动排课系统(共11页).docx)为本站会员(飞****2)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开