现在位置: 首页 > taro发表的所有文章
  • 06月
  • 02日
综合 ⁄ 共 766字 评论关闭
1.描述 Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note: Recursive solution is trivial, could you do it iteratively? 2.思路 a.先遍历左子树直至左孩子为空 b.然后看当前节点的右子树是否为空,为空,则访问当前节点,弹出当前节点,重新判断;不为空,访问当前节点,然后将当前节点弹出,并将当前节点的右孩子进栈,返回a c.这中间需要注意的是,在弹出当前节点后,在获得栈顶的当前节点前先......
阅读全文
  • 04月
  • 15日
综合 ⁄ 共 2680字 评论关闭
几乎和1554 Folding是一样的题目,区别是这更简单一点。LRJ黑书里拿做动态规划例题的第一道。 类似邮局问题的划分,注意左右有挂号时的状态。   1#include <cstdio>  2#include <string>  3  4#define min(x,y) ( x < y ? x : y )  5  6int T, m[101][101], L, ch[101][101];  7char str[101];  8  9void dp (); 10int get ( int, int ); 11void init (); 12void print ( int, int ); 13 14int main () 15{ 16    //freopen ( "bracket.in", "r", stdin ); 17    scanf ( "%d", &T ); 18    gets ( str ); ......
阅读全文
  • 01月
  • 13日
综合 ⁄ 共 4235字 评论关闭
Find a way Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2648    Accepted Submission(s): 848 Problem Description Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki. Yifenfei’s home is at the countryside, but Merceki’s home is in the center of city. So yifenfei made arrangements with Merceki to meet at a KFC. Th......
阅读全文
  • 06月
  • 06日
综合 ⁄ 共 793字 评论关闭
/**********************************************************************  功能:将十六进制数据转换成十进制数据。  原理:        n最初为零,(cbHex[i]-'0')是真实的数字大小,这样n最初为   输入十六进制数的最左位,然后通过左移不停乘以16冥次方。   假设你输入的16进制数为:450   第一个循环结束,n=0+4;   第二个循环结束,n=(0+4)*16+5 = 4*16+5   第三个循环结束,n=(4*16+5)*16+0 = 4*16*16 + 5*16 + 0   从而实现了十六进制向10进制的转换***********************************************************************......
阅读全文
  • 05月
  • 26日
综合 ⁄ 共 3948字 评论关闭
Declaring Swift Enumerations Just about every programming language has the concept of enumerations. An enumeration allows you to group a set of related constants together. It contains a complete list of all the possible values for a given type.  In Swift, you declare a simple enumeration as follows: This enumeration contains a complete list of all the functions available on a very simple calculator. Each case keyword declares a separate  member of the enumeration. You can also dec......
阅读全文
  • 04月
  • 19日
综合 ⁄ 共 2276字 评论关闭
一般来说,系统提供的方法已经足够开发了,但是有的时候有些需求用普通方法不好做。 如:在所有的viewcontroll 的viewwillappear:方法之前打个log 你可能会这么做: 1. 建一个uiviewcontroll 父类,重写viewwillappear方法,调用super viewwillappear 方法之前加上log 2. 所有新建的uiviewcontroller 继承第一步生成的 确实你是完成这样的功能,可是你做了那么多的修改,基本每个uiviewcontroller都去修改了父类,这种方法太过于笨重了 本文提供了简单地方法即可实现 我的理解中,object-c 的类调用方法是根据三个元素来定义的......
阅读全文
  • 02月
  • 13日
综合 ⁄ 共 1864字 评论关闭
[cpp] view plaincopy //创建不可改变的词典      NSDictionary * dictionary;   dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"good lucky",@"why",@"bye bye",@"how",nil];   //里面的元素个数是奇数(不包括最后的 nil)的话是不可以的,偶数才行,因为是 id  key 一组一组对应的      //输出词典的数量   NSLog(@"词典的数量= %lu",[dictionary count]);      /*得到词典中所有的键值的过程  NSEnumerator 用来遍历集合中每一处索引的对象*/      //先得到里面所有的键值   objectEnume......
阅读全文
  • 02月
  • 07日
综合 ⁄ 共 1071字 评论关闭
文章目录 Apache Tomcat/5.5.14         虽然我们写程序都尽力去避免错误,然而有一种情况却是很难避免的,那就是如果有人故意输入或者说是程序故障,访问到了不存在的地址,那么就会显示一堆404的出错信息,如下:   HTTP Status 404 - There is no Action mapped for namespace /example and action name SaveTest1. type Status report message There is no Action mapped for namespace /example and action name SaveTest1. description The requested resource (The......
阅读全文
  • 01月
  • 23日
综合 ⁄ 共 759字 评论关闭
//设置文本选中高亮 function setTextSelected(inputDom, startIndex, endIndex){    if (inputDom.setSelectionRange)    {          inputDom.setSelectionRange(startIndex, endIndex);      }       else if (inputDom.createTextRange) //IE     {        var range = inputDom.createTextRange();          range.collapse(true);          range.moveStart('character', startIndex);          range.moveEnd('character', endIndex - startIndex-1);          range.select();    }      inputDom.focus();  }   //获取选......
阅读全文
  • 01月
  • 20日
综合 ⁄ 共 1916字 评论关闭
Pseudoforest Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1790    Accepted Submission(s): 687 Problem Description In graph theory, a pseudoforest is an undirected graph in which every connected component has at most one cycle. The maximal pseudoforests of G are the pseudoforest subgraphs of G that are not contained within any larger pseudoforest of G. A pesudoforest is larger than another if and only if the total value of the e......
阅读全文
  • 01月
  • 09日
综合 ⁄ 共 2352字 评论关闭
一、inittab文件背景(1)init进程的作用   使用uboot下载Linux内核时,环境变量bootargs决定了kernel向根文件系统传递的参数,这些参数包括      bootargs=noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0   <1>root:指定了根文件系统在Flash分区中的位置   <2>console:指定了内核启动后首选的控制台.   <3>init:指定了Linux内核启动完毕后调用的第一个、也是唯一的一个用户态进程,即进程号为1的进程.其中,参数"init=linuxrc"非常重要.由于init进程是kernel启动后的第一个、也是唯一的一个用户态......
阅读全文
  • 12月
  • 19日
综合 ⁄ 共 1614字 评论关闭
  #include"stdio.h"  #include"stdlib.h"  typedef int ElementType;  typedef struct Queue  {      int rear,front;      ElementType *elements;      int MaxSize;  }Queue;  void InitQueue(Queue *Q,int sz)//初始化  {      Q->MaxSize=sz;      Q->elements=(ElementType *)malloc(sizeof(ElementType)*Q->MaxSize);      Q->front=Q->rear=0;  }  void freeQueue(Queue *Q,int sz)//释放空间  {      free(Q->elements);  }  void MakeEmpty(Queue *Q)//置空  {      Q->front=Q->rear=0;  }  i......
阅读全文