qingcheng奕  
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 23 下一页

2014年4月29日

摘要: auto:推导类型变量:编译器选项指示编译器如何使用auto 关键字来声明变量。如果指定默认选项/Zc:auto,编译器从其初始化表达式中推导声明的变量的类型。如果指定/Zc:auto-,编译器将该变量分配给自动存储类。使用示例:auto root = new TreeNode(*pre_first... 阅读全文
posted @ 2014-04-29 21:39 qingcheng奕 阅读(869) 评论(0) 推荐(0)

2014年4月28日

摘要: http://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/根据二叉树的前序遍历和中序遍历序列求二叉树学习:迭代器的使用和auto变量#include #include using... 阅读全文
posted @ 2014-04-28 22:32 qingcheng奕 阅读(156) 评论(0) 推荐(0)

2014年4月27日

摘要: http://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/知道二叉树的中序遍历和后序遍历序列,求二叉树。使用递归#include #include using namespac... 阅读全文
posted @ 2014-04-27 17:07 qingcheng奕 阅读(150) 评论(0) 推荐(0)

2014年3月12日

摘要: #include"StdAfx.h" #include#include#include #include #include /********函数变量声明********/ #define PR_Box printf("■") #define PR_Gold printf("★") #define PR_Ag printf("☆") #define PR_FBird printf("Ю") #define PR_DBird printf("Ф") #define PR_Lan 阅读全文
posted @ 2014-03-12 21:39 qingcheng奕 阅读(249) 评论(0) 推荐(0)

2014年3月5日

摘要: counts = [98,12,3,4,1,4,9,3821]minNum = min(counts)#print minNumminNum_index = counts.index(minNum)#print minNum_index#找出列表中最小的2个元素def find_two_smallest(L): smallest = min(L) min_index = L.index(smallest) L.remove(smallest) smallest2 = min(L) min_index2 = L.index(smallest2) L.r... 阅读全文
posted @ 2014-03-05 20:41 qingcheng奕 阅读(227) 评论(0) 推荐(0)

2014年2月21日

摘要: 输入 str1 = raw_input("Plz input a string:")输出 print(str1)print(5)print(12.5)print('H')print('wwww' )print x , y , zhelp(raw_input)变量:可变化数据的程序标识符,指向某个数据单元,通过赋值可以改变其指向(而不是上一个单元里的数据),指向内存单元的变,类似C中的指针。不分数据类型,指向什么样的就算是什么类型的变量。id(x)打出x指向的单元的地址字符函数库:help(str) s = "Python" 阅读全文
posted @ 2014-02-21 10:40 qingcheng奕 阅读(317) 评论(0) 推荐(0)

2014年2月15日

摘要: http://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/树的层序遍历,和上一道题相比,对结果做一个顺序调整 reverse()/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {p... 阅读全文
posted @ 2014-02-15 12:46 qingcheng奕 阅读(148) 评论(0) 推荐(0)
 
摘要: http://oj.leetcode.com/problems/binary-tree-level-order-traversal/树的层序遍历,使用队列由于树不是满的,还要分出每一层来,刚开始给缺少的节点用dummy节点代替,结果超时了。vector > levelOrder(TreeNode *root) { vector > ans; if(root == NULL) return ans; int num = 1,num2 = 1; queue myQueue; myQueue.push(roo... 阅读全文
posted @ 2014-02-15 12:27 qingcheng奕 阅读(155) 评论(0) 推荐(0)
 
摘要: http://oj.leetcode.com/problems/binary-tree-postorder-traversal/树的后序遍历,可以使用递归,也可以使用栈,下面是栈的实现代码#include #include #include using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class Solution {public: vec... 阅读全文
posted @ 2014-02-15 11:08 qingcheng奕 阅读(155) 评论(0) 推荐(0)
 
摘要: http://oj.leetcode.com/problems/binary-tree-preorder-traversal/二叉树的先跟遍历,写的是递归版本,也可以使用stack来进行,替代了递归函数。class Solution {public: void preOrder(TreeNode *root,vector &ans) { ans.push_back(root->val); if(root->left) preOrder(root->left,ans); if(root->right) pr... 阅读全文
posted @ 2014-02-15 09:48 qingcheng奕 阅读(134) 评论(0) 推荐(0)
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 23 下一页