摘要: 下午效率不是很高。在收尾的时候把两棵树的显示分开了,更有“森林”的感觉。但是美中不足的每棵树的最后一个节点还是有“->",虽然我已经模仿Yan版教材加上了begin&end,稍微看着不那么突兀。本想写个判断把最后那个箭头删了,目前还是没有成功…… 1 #include <iostream> 2 using namespace std; 3 4 template <class TElemType> 5 struct Treenode 6 { 7 TElemType data; 8 Treenode<TElemType> *lchild, 阅读全文
posted @ 2012-02-23 18:59 uniquews 阅读(1060) 评论(0) 推荐(0) 编辑
摘要: 之前只有十字链表的创建,这篇包含创建和输出两个函数,用c++模板类实现。 1 #include <iostream> 2 3 using namespace std; 4 5 template <class TElemType> 6 class Graph 7 { 8 public: 9 void CreateOlgraph(); 10 void PrintOlgraph(); 11 private: 12 struct ArcBox 13 { 14 int headvex,tailvex; 15 ArcBox *hlink... 阅读全文
posted @ 2012-02-23 12:53 uniquews 阅读(2439) 评论(0) 推荐(0) 编辑
摘要: 基础不扎实 >_<!C++中传值参数和引用参数怎样区别呢?看以下例子:#include<iostream>using namespace std;void swap(int a,int b){int temp;temp=a;a=b;b=temp;}main(){int a=3,b=5;cout<< "before ‘swap’:a="<<a<<",b="<<b<<endl;swap(a,b);cout<<"after‘swap’:a="&l 阅读全文
posted @ 2012-02-23 10:39 uniquews 阅读(395) 评论(0) 推荐(0) 编辑