⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prg16_3.cpp

📁 这是数据结构和算法的国外经典书籍.清华大学出版社出版的<数据结构C++语言描述-应用模板库STL>陈君 译 英文名称是Data Structures with C++ Using STL.
💻 CPP
字号:
#ifdef _MSC_VER
// disable warning messages that identifier was truncated
// to 'number' characters in the debug information
#pragma warning(disable:4786)
#endif	// _MSC_VER

// File: prg16_3.cpp
// the program inputs a directed acyclic graph that describes course
// prerequisites in a religious studies departmen. it performs
// a topological sort and outputs the result as a possible schedule
// of courses

#include <iostream>
#include <string>
#include <list>

#include "d_graph.h"
#include "d_util.h"

using namespace std;

int main()
{
	// graph specifying the courses and prerequisite edges
	graph<string> g;

	// a list holding the topological order of courses
	list<string> tlist;

	// input file holding the vertex strings and edges
	ifstream graphIn;

	// open the file and input the graph
	graphIn.open("courses.dat");
	graphIn >> g;

	// execute a topological sort; store results in list
	topologicalSort(g,tlist);

	// output the list of possible courses 
	cout << "Possible schedule of courses"
		  << endl << "    ";
	writeContainer(tlist.begin(), tlist.end());
	cout << endl;

	return 0;
}

/*
Run:

Possible schedule of courses
    R51  R53  R173  R151  R37  R137  R63  R263
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -