排课程序源码


挺不错的东西,分享一下,许多都是原创的,下载后可以多研究一下。
资源截图
代码片段和文件信息
/*
  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


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)