- 博客(15)
- 问答 (1)
- 收藏
- 关注
原创 graphl.h
#ifndef GRAPHL_H #define GRAPHl_H #include #include "graph.h" using namespace std; // node data element struct listUnit { int vertex; // 顶点 int weight; // 边的权 }; // linked li
2015-07-26 19:44:18
510
原创 graphm.h
/* 1. 二维数组存储边的权值, 权为零表示边不存在 */ #ifndef GRAPHM_H #define GRAPHM_H #include #include "graph.h" using namespace std; class Graphm : public Graph { private: int **matrix; public: Graphm(int numVe
2015-07-26 19:42:09
410
原创 graph.h
#ifndef GRAPH_H #define GRAPH_H #include #include using namespace std; const int UNVISITED = 0; const int VISITED = 1; class Edge { public: int from; //edge start point int to; //edge end p
2015-07-26 19:40:00
1649
原创 arrlist
/* 1. 插入删除等位置参数指数组下标 * 2. 判断条件有:表是否已满; 位置是否合法 */ #ifndef LIST_H #define LIST_H #include using namespace std; template class arrList { private: T* aList; int maxSize; int curLen; int positio
2015-07-22 21:59:42
567
原创 lnklist
/* 1. head->next第一个元素, 位置为0 * 2. setPos(-1) return head * 3. 删除和插入先定位到前一个结点 * 4. 尾结点为临界情况,需要特殊处理 */ #ifndef LNKLIST_H #define LNKLIST_H #include using namespace std; template class Node { publ
2015-07-22 21:55:05
398
原创 cout.get() P494
#include #include using namespace std; int main () { char ch; while ( ( ch = cin.get() ) != EOF) cout.put(ch); return 0; }
2015-06-06 23:17:42
544
原创 输入输出--数值转换为字符串
#include #include #include using namespace std; template inline string toString(const T &v) { ostringstream os; os<<v; return os.str(); } int main() { string str1 = toString(5); cout<<str1<<
2015-06-06 22:51:19
542
原创 输入输出--write
#include using namespace std; struct Date { int mondy, day, year; }; int main() { Date dt = {7, 27, 93}; ofstream file("date.dat", ios_base::binary); file.write(reinterpret_cast(&dt), sizeof(d
2015-06-06 22:41:22
391
原创 输入输出控制
#include #include #include using namespace std; int main() { int values[] = {111, 123, 653, 43584}; string names[] = {"Zoot", "Jimmy", "Al", "Stan"}; cout<<setiosflags(ios_base::fixed); for(
2015-06-06 21:55:05
470
原创 流类库与输入输出--精度
#include #include #include using namespace std; int main() { double values[] = {1.23, 35.36, 653.7, 4358.24}; string names[] = {"Zoot", "Jimmy", "Al", "Stan"}; for(int i = 0; i < 4; i++) co
2015-06-06 21:42:56
397
原创 流类库与输入输出--对齐方式
#include #include #include using namespace std; int main() { double values[] = {1.23, 35.36, 653.7, 4358.24}; string names[] = {"Zoot", "Jimmy", "Al", "Stan"}; for(int i = 0; i < 4; i++) co
2015-06-06 21:40:37
416
原创 palindrome number
#include using namespace std; bool pail(unsigned n) { unsigned i = n; unsigned m = 0; while(i > 0) { m = m*10+i%10; i /= 10; } return m == n; } int main() { unsigned m=0; do { cou
2015-06-06 00:45:21
312
原创 类模板(函数模板)
#include using namespace std; template T abs(T x) { return x < 0?-x:x; } int main() { int n = -5; double d = -5.5; cout<<abs(n)<<endl; cout<<abs(d)<<endl; return 0; }
2015-06-01 20:56:18
252
原创 Visitor Pattern -- 基于编译试验抽象语法树 (C++)
1. Visitor.h #ifndef VISITOR_H #define VISITOR_H class Visitor; class Node { public: virtual void Accept(Visitor &v) = 0; }; class Exp : public Node {}; class Unary : public Exp
2015-05-31 22:13:39
711
原创 Tower of Hanoi (递归的神奇之力--化繁为简)
/* *Tower of Hanoi* */ #include using namespace std; void move(char s, char d) { cout"<<d<<endl; } /* s is source tower, d is target tower m is middle tower, n id the number of diskes */ void
2015-05-31 22:05:10
448
空空如也
怎么再网页显示本地文件缩略图?
2015-08-10
TA创建的收藏夹 TA关注的收藏夹
TA关注的人