資源簡介
C++ 排課程序源代碼,包含兩個排課程序:
Course_Arrangement用C++寫的自動排課程序
遺傳算法做排課軟件源碼
其中第二個源碼也就是遺傳算法做排課軟件做的比較詳細,源代碼較豐富,也是比較早的C++程序,全部看完看懂需要點耐心。

代碼片段和文件信息
/*
??File?Name:????Course_Arrangement.cpp
??Intro????:????This?program?realize?the?arragement?of?courses
??Author???:????Wang?Ting
??Download?:????http://www.codefans.net
??Date?????:????2009-11-29
??Language?:????C++
??Run?Platform:?Linux/Unix
*/
#include?“course.h“
course::course()
{
days=0;
num_class=0;
}
SUB?*create_form()??????????//create?form?(read?datas?to?SUB?from?file?you?given)
{
?ifstream?infile;
?string?inputFile;
?SUB?*head*tail*p;
//?????course?cor;
?int?size=sizeof(SUB);
?head=tail=NULL;
?cout<<“Enter?the?file?path:?“;
?cin>>inputFile;?
?cout< ?infile.open(inputFile.c_str());
?int?i=0;
?while(i<15){
?i++;
?p=(SUB?*)malloc(size);
?infile>>p->number;
?infile>>p->name;
?infile>>p->students;
?infile>>p->status;
// ?cor.subs[i]=p;
?if(head==NULL)
???head=p;
?else
??tail->next=p;
??????tail=p;
?}
?tail->next=NULL;
?return?head;
}
SUB1?*create_form1()???????????????//create?form?(read?datas?to?SUB?from?file?subject.txt)
{
?ifstream?infile1;
?string?inputFile1=“.\\subject.txt“;
?SUB1?*head1*tail1*p1;
?int?size1=sizeof(SUB1);
?head1=tail1=NULL;
?infile1.open(inputFile1.c_str());
?int?i=0;
?while(i<15){
?i++;
?p1=(SUB1?*)malloc(size1);
?infile1>>p1->number1;
?infile1>>p1->name1;
?infile1>>p1->students1;
?infile1>>p1->status1;
?if(head1==NULL)
???head1=p1;
?else
??tail1->next1=p1;
??????tail1=p1;
?}
?tail1->next1=NULL;
?return?head1;
}
SUB?*create_form2()??????????????//create?form?(read?datas?to?SUB?from?data.txt)
{
?ifstream?infile;
?SUB?*head*tail*p;
?int?size=sizeof(SUB);
?head=tail=NULL;
?????string?inputFile=“.\\data.txt“;
?infile.open(inputFile.c_str());
?int?i=0;
?while(i<15){
?i++;
?p=(SUB?*)malloc(size);
?infile>>p->number;
?infile>>p->name;
?infile>>p->students;
?infile>>p->status;
?if(head==NULL)
???head=p;
?else
??tail->next=p;
??????tail=p;
?}
?tail->next=NULL;
?return?head;
}
void?initi(SUB?*head)??????//?initialization
{
SUB?*p;
????for(p=head;p;p->next)
{
p->status=-1;
}
}
bool?canchoose(int?num_class)????//?function?decides?if?the?class?can?be?chosenreturn?bool
{
????SUB?*head;
SUB?*p;
head=create_form();
bool?choose=false;
????for?(p=head;p;p->next)
{
??if(p->status!=num_class)?
??{
??choose=true;
??}
??else
??{?
??choose=false;?
??}
?? ??break;
}
return?choose;
}
void?choosecourse(int?numint?num_class)??//?function:?choose?course?according?to?number?of?course?and?time
{
????SUB?*p;
SUB?*head;
head=create_form();
for(p=head;p;p->next)
{
if(canchoose(num_class)?&&?p->number==num)?
{
p->status=num_class;?
break;
}
}
}
void?printout(SUB1?*head1)???//?function?:output?the?arrangement?information
{
///////////////////output?on?the?file?arrange.txt/////////////////////////////////
?SUB1?*p1;
?FILE?*fpp;
?if((fpp=fopen(“.\\ar
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
-----------?---------??----------?-----??----
?????????????10012604????????????????????717
評論
共有 條評論