摘要: // 栈.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include using namespace std;typedef char ElemType;#define MAX_INI... 阅读全文
posted @ 2014-06-10 20:29 menghuizuotian 阅读(304) 评论(0) 推荐(0)
摘要: 这一题如果是采用暴力手段,不一定能获得正确答案,而且也非常耗时。所以下面我们采用一个小技巧,也就是先产生n-1个红包,总得sum#include #include #define min(x,y) (x) &vec){ if(sumM0) { srand((int)time... 阅读全文
posted @ 2014-06-10 16:28 menghuizuotian 阅读(788) 评论(0) 推荐(0)
摘要: 题目:输入一个矩阵,按照从外到里以顺时针顺序依次打印每一个数字 例如:如果输入如下矩阵:1 2 3 45 6 7 89 10 11 1213 14 15 16则依次打印出数字1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10。 分析:突破点就是先要画图,如下图 每次打印一个圈,接下来下一圈的左上角坐标点为起点再打印。 其中需要考虑在打印每一... 阅读全文
posted @ 2014-06-10 13:29 menghuizuotian 阅读(349) 评论(0) 推荐(0)
摘要: 题目:完成一个函数,输入一个二叉树,该函数输出它的镜像 分析:何为镜像? 首先我们先去遍历头结点,如果不为空,那么我们就要继续遍历其左子树和右子树,如果不为空就进行一个交换,这里要说明的是:树的根节点与其左右子树之间是采用指针的形式进行一个连接的,也就是你交换了左右子树(比如 10 6),但是子树(10,6)下面对应的子树(比如10 对应11,9, 6对应7,5)之间的连接是不变的。 直到其左右... 阅读全文
posted @ 2014-06-10 10:38 menghuizuotian 阅读(229) 评论(0) 推荐(0)