[例8.1]最简单的例子. #include <iostream> using namespace std; class Time //定义Time类 { public : //数据成员为公用的 int hour; int minute; int sec; }; int main( ) { Time t1;//定义t1为Time类对象 cin>>t1.hour;//输入设定的时间 cin>>t1.minute; cin>>t1.sec; //输出时间: co
Graph: class Graph(dict): def __init__(self, vs=[], es=[]): for v in vs: self.add_vertex(v) for e in es: self.add_edge(e) # 必须全部的顶点添加完毕之后,才可以添加新的边进去 def add_vertex(self, v): self[v] = {} def add_edge(self, e): v, w = e self[v][w] = e self[w][v] = e #