- 博客(20)
- 资源 (1)
- 收藏
- 关注
原创 获取navigationcontroller栈中的倒数第二个视图控制器
我上传app两次都被拒,最后发现我修改后的代码需要也把获取navigationcontroller栈中的最后一个视图控制器修改为获取navigationcontroller栈中的倒数第二个视图控制器,查了下资料在点击打开链接找到了解决方案: 原理就是把navigationController栈中的视图控制器存到一个数组里,然后从这个数组里就可以任意获取自己想要的视图控制器了。 // 获取
2013-04-04 22:41:03
5437
原创 题目:已知一个完全二叉树的结点数为770,问完全二叉树的叶子结点数为多少?
前一段参加招聘笔试,遇到了这道题,当时连完全二叉树的定义都不太记得了,虽然我答对了但是感觉费了好长时间,心想作为程序员这种题应该编程解决,不要人去算,这也是我最近的领悟,程序就是用来解决问题的,所以我又看了一下数据结构二叉树那一章,推导了一下,发现其实挺简单的。 我们设度数为0,1,2的结点分别为n0, n1, n2, 总的结点数为 n。则有: n = n0 + n1 + n2; 另,根据
2013-03-24 21:43:26
3684
原创 剑指offer-->面试题7 用两个栈实现队列
下面是Queue.h #pragma once #include #include using namespace std; template class CQueue { public: CQueue(void); ~CQueue(void); void appendTail(const T &node); T deleteHead(); private: stac
2013-02-19 15:54:31
508
原创 妙趣横生的算法实例2-2-->折半查找
源代码如下: #include int binSearch(int key[], int n, int k) { int low = 0, high = n - 1, mid; while(low <= high) { mid = (low + high) / 2; if(key[mid] == k) { return mid; }else if(key[mid]
2013-02-15 20:15:47
500
原创 剑指offer-->面试题6 重建二叉树
下面是源代码: #include struct BinaryTreeNode { int m_nValue; BinaryTreeNode *m_pLeft; BinaryTreeNode *m_pRight; }; BinaryTreeNode *ConstructCore(int *startPreorder, int *endPreorder, int *startInorde
2013-02-08 13:29:07
1200
原创 妙趣横生的算法实例1-7
下面是源代码: #include #include int visited[5] = {0, 0, 0, 0, 0}; typedef struct ArcNode { int adjVex; struct ArcNode *next; }ArcNode; typedef struct VNode { int data; ArcNode *firstArc; }VNode;
2013-02-08 09:49:50
483
原创 妙趣横生的算法实例1-7
下面是源代码: #include #include int visited[5] = {0, 0, 0, 0, 0}; typedef struct ArcNode { int adjVex; struct ArcNode *next; }ArcNode; typedef struct VNode { int data; ArcNode *firstArc; }VNode;
2013-02-06 19:17:42
1253
原创 AQGridView开源库中的示例DEMO:SpringBoard中为什么需要empty cell
这几天在看AQGridView开源库中的示例DEMO:SpringBoard,一直不明白里面为什么会有empty cell,看了几遍代码终于明白了。 先看下面的代码: case UIGestureRecognizerStateBegan: { NSLog(@"UIGestureRecognizerStateBegan"); NSU
2013-01-22 14:59:22
1798
原创 剑指offer-->面试题5 从尾到头打印链表
#include #include typedef struct ListNode { int m_nValue; ListNode *m_pNext; }ListNode; ListNode *createListNode(int value) { ListNode *node = new ListNode(); node->m_nValue = value; node->m_
2013-01-20 19:53:32
1492
原创 妙趣横生的算法实例1-6
我想这道题时,一直想不到该怎么样使从下一层返回上一层时,上一层数不变,因为我想在遍历里面定义一个变量,怎么也行不通,看了书上是又多传进来一个参数,这个问题就迎刃而解了。 #include #include typedef struct biTNode { char data; struct biTNode *lChild, *rChild; }biTNode, *biTree; vo
2013-01-16 21:01:13
428
原创 剑指offer-->面试题4 替换空格
我想到了从前往后移,不过时间复杂度是O(n^2),从后往前移,时间复杂度可以降到O(n)。下面是O(n)的代码: #include #define LENGTH 100 void replaceSpace(char *str, int length) { int i = 0; int numberOfChar = 0; int numberOfSpace = 0; int inde
2013-01-13 19:23:19
1015
原创 妙趣横生的算法实例1-5
#include #include typedef struct qNode { char data; struct qNode *next; }qNode, *queuePtr; typedef struct { queuePtr front; queuePtr rear; }linkQueue; void initQueue(linkQueue *q) { q->fron
2013-01-12 21:24:17
527
原创 c语言使用free函数之后
我一直对c语言使用free函数之后,指针所指向的内容有什么变化比较迷惑,所以写了个程序,看看到底是什么的结果。 #include #include typedef struct node { int data; struct node *next; }node, *nodePtr; void main() { nodePtr p = (nodePtr)malloc(sizeof(n
2013-01-12 21:17:55
1430
原创 剑指offer-->二维数组中的查找
这个答案不是我想出来的,而是看的书上的,然后我把答案默写出来了,不过改成c语言下可以正确运行的了,令我没想到的是c语言竟然没有bool类型,结果代码一直出错。 这里面也用到了这样一个知识点:在C/C++中,当数组作为函数的参数进行传递时,数组就自动退化为同类型的指针。 #include typedef int bool; #define true 1 #define false 0 bo
2013-01-09 21:15:26
678
原创 妙趣横生的算法实例1-4
#include #include #include #define STACK_INIT_SIZE 10 #define STACK_INCREMENT_SIZE 10 typedef char ElemType; typedef struct { ElemType *base; ElemType *top; int stackSize; }stack; void init
2013-01-06 21:15:31
575
原创 妙趣横生的算法实例1-3
#include #include typedef struct node { int data; struct node *next; }LNode, *LinkList; void destroyLinkList(LinkList *list) { LinkList p, r; p = *list; while(p) { r = p->next; free(p);
2013-01-02 19:01:59
446
原创 自己写的一个CoreData的Demo,实现了增删改查。
自己写的一个CoreData的Demo,实现了增删改查。 文件名:StudentRecordDemo.zip, 访问地址:点击打开链接
2013-01-02 13:13:54
1382
1
原创 妙趣横生的算法实例1-2
下面是我写的答案,感觉比书上写的答案还符合题意: #include #include #define MaxSize 10 typedef struct { int *elem; int length; int listSize; }Sqlist; void initSqlist(Sqlist *L) { L->elem = (int *)ma
2012-12-31 13:15:33
415
原创 妙趣横生的算法实例1-1
下面是我写的答案: #include #define MaxSize 10 int Sqlist[MaxSize]; int len = 0; void show(int length) { int i = 0; int tmp = length; while(tmp > 0) { printf("%d ", Sqlist[i]); i++; t
2012-12-31 13:11:41
636
1
原创 EGOTableViewPullRefresh-master(下拉刷新)过程的理解
EGOTableViewPullRefresh:点击打开链接https://github.com/enormego/EGOTableViewPullRefresh RootViewController.m中的 //把EGORefreshTableHeaderView *view接到tableview的上面,所以坐标是(0,-460,320,460),这样下拉出来的就是EGORefreshT
2012-11-29 14:19:03
1976
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人