摘要: 引用作为返回值 1.通过使用引用来替代指针,会使 C++ 程序更容易阅读和维护。 2.C++ 函数可以返回一个引用,方式与返回一个指针类似。 3.当函数返回一个引用时,则返回一个指向返回值的隐式指针。这样,函数就可以放在赋值语句的左边。 注意: (1)以引用返回函数值,定义函数时需要在函数名前加 ( 阅读全文
posted @ 2019-09-25 19:55 煊奕 阅读(2117) 评论(0) 推荐(2) 编辑
摘要: 分析 + 栈:后进先出 + 队列:先进先出 要使用两个栈实现队列(先进先出),主要思路是 1.插入一个元素:直接将元素插入stack1即可。 2.删除一个元素:当stack2不为空时 ,直接弹出栈顶元素,当stack2为空时,将stack1元素逐个弹出并压入stack2,然后再弹出栈顶元素。 具体看 阅读全文
posted @ 2019-09-25 19:46 煊奕 阅读(2836) 评论(0) 推荐(2) 编辑
摘要: DDL(Data Definition Language)数据库定义语言 statements are used to define the database structure or schema. DDL用于定义数据库的三级结构,包括外模式、概念模式、内模式及其相互之间的映像,定义数据的完整性、 阅读全文
posted @ 2019-09-24 23:41 煊奕 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 分析 1.归纳:求出前几个的方法数: 1 1 2 2 3 4 4 8 ... 可推出:F(n) = 2 F(n 1) 递归求解 C++ class Solution { public: int jumpFloorII(int number) { if(number 阅读全文
posted @ 2019-09-23 23:40 煊奕 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 遍历规则 + 前序遍历:根结点 左子树 右子树 + 中序遍历:左子树 根结点 右子树 + 后序遍历:左子树 右子树 根结点 + 层次遍历:只需按层次遍历即可 注: 1.前序、中序、后序属于深度优先遍历(使用递归较为方便),层次遍历为广度优先遍历(一般实现需要借助其他数据结构的支撑,如下面的队列等)。 阅读全文
posted @ 2019-09-22 22:28 煊奕 阅读(1472) 评论(0) 推荐(0) 编辑
摘要: ```C++ //十进制转十进制以下的其他进制 include include using namespace std; int main() { int T; int n, a, p; cin T; while (T ) { stack s; //n 为十进制,p为要转换的进制 cin n p; 阅读全文
posted @ 2019-09-21 23:33 煊奕 阅读(121) 评论(0) 推荐(0) 编辑
摘要: ```C++ include using namespace std; template class Queue { public: Queue(); bool isEmpty() const; bool isFull()const; void enQueue(const T&); T deQueu 阅读全文
posted @ 2019-09-21 19:04 煊奕 阅读(1930) 评论(0) 推荐(0) 编辑
摘要: ```C++ include //栈的数组实现 using namespace std; define MAXSIZE 10; template class Stack { public: //默认构造函数 Stack(); Stack(size_t maxElements); Stack(T da 阅读全文
posted @ 2019-09-20 22:22 煊奕 阅读(2775) 评论(0) 推荐(0) 编辑
摘要: 反序输出一个整数 C++ include using namespace std; int main() { int n; while (cin n)//输入一个整数 { int temp = 0;//temp作为存储的值 while (n != 0){ temp = temp 10 + n % 1 阅读全文
posted @ 2019-09-20 20:37 煊奕 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 二分查找 C++ include using namespace std; //非递归实现 int BinarySearch(int array[], int len, int value) { if (array == NULL || len value) high = mid 1; else l 阅读全文
posted @ 2019-09-19 21:34 煊奕 阅读(184) 评论(0) 推荐(0) 编辑