摘要:
树节点定义:struct Node { int data; Node *left; Node *right; };递归实现:void visit(Node *node) { assert(node != NULL); printf("%d ", node->data);}void visitPrevOrderRec(Node *tree) { if (tree == NULL) return ; visit(tree); visitPrevOrderRec(tree->left); visitPrevOrderRec(tree->rig... 阅读全文
摘要:
经测试效率比apple版差一点点,我已经满足了。static inline intisspace(char c){ return (c == ' ' || c == '\t' || c == '\n' || c == '\12');}static inline intisupper(char c){ return (c >= 'A' && c <= 'Z');}static inline intislower(char c){ return (c >= 'a 阅读全文
摘要:
1 static inline int 2 isupper(char c) 3 { 4 return (c >= 'A' && c <= 'Z'); 5 } 6 7 static inline int 8 isalpha(char c) 9 { 10 return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); 11 } 12 13 14 static inli 阅读全文
摘要:
下面是网上找的一个itoa实现。刚开始觉得应该在函数最开始的时候判断value的正负,如果是负的就转化为正数,这样就不需要使用字符串“z-a9-0-9a-z”,而只需要使用“0-9a-z”。后来才发现这种方法不能正确的处理INT_MIN,因为-INT_MIN == INT_MIN,依然是负数! /** * C++ version 0.4 char* style "itoa": * Written by Lukás Chmela * Released under GPLv3. */ char* itoa(int value, char* result,... 阅读全文