2020年3月20日
摘要: 分治法 分--将原问题分解成规模更小的子问题,这些子问题相互独立且与原问题形式相同治--将这些规模更小的子问题逐个击破合--分解出的子问题的解可以合并为原问题的解 贪心算法 在对问题求解时,总是做出当前看来最好的选择,而不是从整体上加以考虑希望通过一系列局部的最优选择,能够产生整个问题的最优解局部最 阅读全文
posted @ 2020-03-20 18:18 ~明月几时有 阅读(394) 评论(0) 推荐(0)
  2020年3月18日
摘要: C++和Python都是面向对象的高级程序设计语言 C++是一门编译型语言,源程序经过预处理、编译和链接之后生成可执行文件 Python是一门解释型语言,Python解释器先把源代码转换成字节码文件,再由Python虚拟机一条一条地执行字节码指令 C++是一种强类型语言,每个变量的类型都需要事先声明 阅读全文
posted @ 2020-03-18 16:23 ~明月几时有 阅读(3129) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; const double PI=3.14159; template<typename T> class Circle{ T radius; static int total; public: Circle(T r=0){ 阅读全文
posted @ 2020-03-18 10:11 ~明月几时有 阅读(286) 评论(0) 推荐(0)
  2020年3月16日
摘要: 第一点:常引用作为参数可以接收普通变量和常量而普通引用作为参数不能接收常量 第二点:不能把常引用参数作为普通引用返回但可以把普通引用参数作为常引用返回 第三点:如果是普通变量接收引用返回或常引用返回因为是引用返回编译器不必复制一份建立匿名对象但用普通变量接收时,会把匿名对象复制一份到普通变量标识的内 阅读全文
posted @ 2020-03-16 10:23 ~明月几时有 阅读(1037) 评论(0) 推荐(0)
  2020年3月14日
摘要: #include <iostream> using namespace std; class Point { public: Point(int x = 0, int y = 0) : x(x), y(y) { count++; } Point(const Point &p) : x(p.x), y 阅读全文
posted @ 2020-03-14 18:17 ~明月几时有 阅读(404) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; class Base1 { public: Base1(int i) { cout << "Constructing Base1 " << i << endl; } ~Base1() { cout << "Destru 阅读全文
posted @ 2020-03-14 18:14 ~明月几时有 阅读(431) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; class Base0 { public: int var0; void fun0() { cout << "Member of Base0" << endl; } }; class Base1: virtual pu 阅读全文
posted @ 2020-03-14 18:12 ~明月几时有 阅读(79) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; class Point{ public: Point(int x=0,int y=0):x(x),y(y){count++;} Point(const Point &p):x(p.x),y(p.y){count++;} 阅读全文
posted @ 2020-03-14 18:06 ~明月几时有 阅读(160) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; class A { public: A(int i); void print(); private: const int a; static const int b; }; //静态常数据成员在类外说明和初始化 con 阅读全文
posted @ 2020-03-14 18:03 ~明月几时有 阅读(947) 评论(0) 推荐(0)
摘要: #include <iostream> using namespace std; class Point { public: Point() : x(0), y(0) { cout<<"Default Constructor called"<<endl; } Point(int x, int y) 阅读全文
posted @ 2020-03-14 17:59 ~明月几时有 阅读(684) 评论(0) 推荐(0)