C
baibaibai66
这个作者很懒,什么都没留下…
展开
-
strlen函数
寻找一种更好的算法比改良一种差劲的算法更有效率。#include <stddef.h> // size_t#define MAXLEN 100#include <stdio.h>size_t strlen (char const *string) { int length; for (length = 0; *string++ != '\0'; ) { // *string++,原创 2016-11-15 10:08:44 · 375 阅读 · 0 评论 -
指针与动态数组
C语言中如何实现动态数组:使用malloc()库函数(内存分配)来得到一个指向一大块内存的指针;像引用数组一样引用这块内存如果需要使数组有动态增长的能力,那就修改内存的总容量,直接在运行时在堆上分配数组的内存。这就用到库函数realloc(),它能够对一个现在的内存块大小进行重新分配(通常是实质扩大),同时不会丢失原先内存块的内容。#include <arpa/inet.h>#include原创 2016-11-15 10:16:19 · 1679 阅读 · 0 评论 -
声明的意义
当定义了一个变量时,它是什么意思呢,这里是一个简单的一次性解释声明的小程序,之后再改一下,可以一次运行,重复输入就OK了。// 无法重复循环该程序#include <stdio.h>#include <ctype.h> // isalnum()#include <string.h> // strcpy()#include <stdlib.h> // atoi()#define MAXTOK原创 2016-11-15 10:22:20 · 578 阅读 · 0 评论 -
C语言操作符顺序
C operators sequence原创 2016-11-18 15:47:49 · 457 阅读 · 0 评论 -
cat
#include <stdio.h>#include <stdlib.h>void filecopy(FILE *ifp, FILE *ofp) { int c; while ((c = getc(ifp)) != EOF) { // #define EOF -1 putc(c, ofp); }}int main(int argc, char *argv[]原创 2016-12-12 14:52:42 · 402 阅读 · 0 评论 -
98. Validate Binary Search Tree
QGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s key. The righ原创 2017-01-13 14:54:57 · 354 阅读 · 0 评论