qingcheng奕  
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 23 下一页

2014年1月1日

摘要: class Solution {public: int numTrees(int n) { if(!n||n==1)return 1; vector numVector; numVector.assign(n+1,0); numVector[0]=1; numVector[1]=1; for(int i=2;i<=n;++i) { for(int j=0;j<=i-1;++j) { numVector[i]+=numV... 阅读全文
posted @ 2014-01-01 14:53 qingcheng奕 阅读(114) 评论(0) 推荐(0) 编辑

2013年12月29日

摘要: http://oj.leetcode.com/problems/rotate-image/将矩阵顺时针旋转90度。要求为原地算法。注意对输入的测试,矩阵为空,长度为1,为2时……#include #include using namespace std;class Solution {public: void rotate(vector > &matrix) { if(matrix.empty()) return; vector >matrixB; vector onePiece; int len = matr... 阅读全文
posted @ 2013-12-29 15:09 qingcheng奕 阅读(153) 评论(0) 推荐(0) 编辑

2013年12月7日

摘要: 参考:https://docs.djangoproject.com/en/1.6/intro/tutorial01/http://rainyang.blog.51cto.com/469543/1152597按照英文教程一步步来,然后遇到问题了再去百度或者google。 阅读全文
posted @ 2013-12-07 19:42 qingcheng奕 阅读(119) 评论(0) 推荐(0) 编辑

2013年12月4日

摘要: 参考资料:http://wenku.baidu.com/link?url=_akpT-G5Tvf7ECyszSipOAhHXzjlpYu-RWPcRTYp_tecPOollPGUxXG4MH69MLNEgWf1aVLFCz65QxL-yph3r0MFCiHJ81I3SWHM8yhBl4O下面是一些语法: 1 __author__ = 'wrq' 2 #coding = utf-8 3 4 import time 5 print("Hello!") 6 7 '定义函数' 8 def test(): 9 nowTime = time.time() 阅读全文
posted @ 2013-12-04 19:51 qingcheng奕 阅读(206) 评论(0) 推荐(0) 编辑

2013年12月3日

摘要: http://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/链表的去重,要考虑链表的本质。#include using namespace std;struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} };class Solution {public: ListNode *deleteDuplicates(ListNode *head) { if(!head) ... 阅读全文
posted @ 2013-12-03 21:02 qingcheng奕 阅读(152) 评论(0) 推荐(0) 编辑

2013年12月2日

摘要: http://oj.leetcode.com/problems/word-break/动态规划题目,重点是建立出模型来:fun(start,end) = fun(start,i)*fun(i+1,end);二维动态数组的申请: int len = s.length(); int **flag = new int *[len]; for(int i = 0;i#include #include using namespace std;class Solution {public: bool fun(string s,unordered_set &dict,int start,int e. 阅读全文
posted @ 2013-12-02 16:05 qingcheng奕 阅读(169) 评论(0) 推荐(0) 编辑

2013年12月1日

摘要: 在做软件度量作业的过程中,遇到了文件中上千条记录的处理。程序如下:C++的读文件字符串取子串等#include #include #include #include using namespace std;int main(){ fstream fin; string filename = "E:\\002Validate Binary Search Tree\\Debug\\bugs-2013-11-30.csv"; fin.open(filename); if(fin.bad()) { cout count; while(!fin... 阅读全文
posted @ 2013-12-01 14:30 qingcheng奕 阅读(179) 评论(0) 推荐(0) 编辑

2013年11月29日

摘要: http://oj.leetcode.com/problems/unique-binary-search-trees-ii/一题要求得出所有树的种类数,二题要求得出所有树。在一题的基础上修改代码,还是要提前想清楚再写。#include #include using namespace std;struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} };cl... 阅读全文
posted @ 2013-11-29 16:54 qingcheng奕 阅读(170) 评论(0) 推荐(0) 编辑

2013年11月25日

摘要: 就是指向函数的指针。回调函数,表示了一个函数的地址,将函数作为参数进行使用。参考百度百科:http://baike.baidu.com/view/414773.htm常用的大概就是在sort函数中了吧。回调函数就是一个通过函数指针调用的函数。如果你把函数的指针(地址)作为参数传递给另一个函数,当这个指针被用来调用其所指向的函数时,我们就说这是回调函数。回调函数不是由该函数的实现方直接调用,而是在特定的事件或条件发生时由另外的一方调用的,用于对该事件或条件进行响应。例子如下:函数:typedefint(__stdcall *CompareFunction)(constbyte*,constbyt 阅读全文
posted @ 2013-11-25 20:10 qingcheng奕 阅读(619) 评论(0) 推荐(0) 编辑

2013年11月23日

摘要: http://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/将一个按照元素升序排列的链表转换成BST。根据自身性质“元素升序排列”,再参考将升序排列的数组转换成BST的上一道题目,只需要将对数组的处理方式变成对链表的。还是得好好利用元素已经升序排列这个性质,不用那种纯粹的重新生成一个BST,按照左转、右转、先左转后右转、先右转后左转。#include #include using namespace std;struct ListNode { int val; ListNode *next;... 阅读全文
posted @ 2013-11-23 16:45 qingcheng奕 阅读(211) 评论(0) 推荐(0) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 23 下一页