grtsdm.cpp

来自「经典c++程序的实现」· C++ 代码 · 共 40 行

CPP
40
字号
#include <stdio.h>
#include <iostream.h>
#include <assert.h>

#include "book.h"

#include "grmat.h"

void printout(int v) {
  cout << v << " ";
}

void tophelp(Graph&, int);

#include "grtsd.c"

main(int argc, char** argv) {
  Graph G;
  FILE *fid;
  int i, j;

  if (argc != 2) {
    cout << "Usage: grtsdm <file>\n";
    exit(-1);
  }

  if ((fid = fopen(argv[1], "rt")) == NULL) {
    cout << "Unable to open file |" << argv[1] << "|\n";
    exit(-1);
  }

  if (!createGraph(G, fid)) {
    cout << "Unable to create graph\n";
    exit(-1);
  }

  topsort(G);
  cout << "\n";
}

⌨️ 快捷键说明

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