// This program implements the topological sort algorithm. The prerequisite // relation is assumed to be stored explicitly in a file as a list of // task names, each occupying a single line. The set of tasks is // assumed to be stored implicitly. Its explicit representation as // an instance of the class "taskset" is constructed from the // components of the pairs of the relation. #include #include #include #include #include #include "mytask4.h" ///////////////////////// MAIN PROGRAM ///////////////////////// // The main program merely creates an input stream given a file, // constructs a taskset given the input stream, // and topologically sorts the taskset to standard output int main(void) { ifstream istr; taskset *s; char filename[FILENMLEN]; cout << "enter input file name: "; cin >> filename; istr.open(filename); if (istr) { s=new taskset(istr); if (!s->bad()) s->topsort(cout); else cout << "ill-formed input" << endl; delete s; } else cout << "file not found" << endl; istr.close(); return 0; }