`
steven-zhou
  • 浏览: 207607 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论
文章列表
/* 假定这个链表只有奇数个节点 */ List *list_middle(List *l) { List *fast; List *slow; fast = slow = l; while (fast != NULL) { if (fast->next) fast = fast->next->next; else return slow; slow = slow->next; } retur ...
/* 编程打印出如下图形 */ * *.*. *..*..*.. *...*...*...*... *....*....*....*....*.... *.....*.....*.....*.....*.....*..... *......*......*......*......*......*......*...... *.......*.......*.......*.......*.......*.......*.......*....... void broom(int n) { int i, j, k; for (i = 1; ...
ifconfig | grep -A 1 'eth0' | grep 'inet addr:' | \ sed 's/.*inet addr://g' | sed 's/[[:blank:]]*Bcast.*//g'
#!/bin/sh # # Line Counter # # Usage: lcnt dir suffix1, suffix2, suffix3 ... # v_dir="$1" v_linenum=0 if [ $# = 0 ]; then echo "=============================================" echo "Usage: lcnt dir suffix1 suffix2 suffix3 ... " echo " ...
#!/bin/sh # # Name: add_del_mod.sh configure file operation script. # # Version: 1.0.0 05-Dec-2008 # Author : tcaosmail@gmail.com # # Description: # add, delete and modify specified record in a # configure file according to parameters. # # Synopsis: add_del_mod FILE [ADD|DEL|MOD] ...
例如: str1为 "asdfsa123fasdf123452345fasfasdf182734891624389sadfaklsjfklj" str2为 "0123456789" 删除后 str1为 "asdfsafasdffasfasdfsadfaklsjfklj" void del_chars(char *str, char *chars) { char ascii_buff[256] = {0}; char buf[strlen(str)]; char *ps1; char *ps ...
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char **argv) { if (argc != 2) { printf("Usage: ./a.out <num>\n"); exit(EXIT_FAILURE); } int n = atoi(argv[1]); int arr[n + 1]; // init ...
//config.h #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #define MAXLEN 256 struct PNode { char *key; char *value; struct PNode *next; }; typedef struct { char *file; struct PNode *first; } Co ...

单词统计

#include <stdio.h> #include <stdlib.h> #include <unistd.h> #define IN 1 #define OUT 0 int main(int argc, char **argv) { int count = 0; int status = OUT; char c; while ( (c = getchar()) != EOF) { if (c != ' ' && c != '\t' && ...
有一整型一维数组,要求在时间复杂度为O(N)的情况下,把小于零的数置于数组的前面,大于零的数放置于数组后面。 void holandflag_sort(int a[], int size) { int i, j, k; i = 0; j = 0; k = size - 1; while (j < k) switch (a[j]) { case RED: swap(a, i, j); i++; j++; ...
/* 非递归实现 */ void reverse(char *s) { char *head; char *tail; char tmp; head = s; tail = head + strlen(s) - 1; while (head < tail) { tmp = *head; *head = *tail; *tail = tmp; head++; tail--; } } /* 递归实现 * ...
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char **argv) { char start; char end; char cur; start = end = '\0'; while ((cur = getchar()) != EOF) { if (cur == '/' && start == '/') { wh ...
/** * if has loop return 1 else return 0 */ static int has_loop(List *list) { List *pFast; List *pSlow; pFast = pSlow = list; if (pFast != NULL && pFast->next != NULL) { pFast = pFast->next->next; } else { return 0; } ...
/* * if list_a and list_b has cross point return the addrss of cross-point. * else return NULL */ static List *has_cross(List *list_a, List *list_b) { List *pa; List *pb; int len_a, len_b; int i; len_a = len_b = 0; pa = list_a; /* 遍历链表a,并记录下此链 ...
// 比如边长为7时: 1 1 1 1 1 1 1 1 2 2 2 2 2 1 1 2 3 3 3 2 1 1 2 3 4 3 2 1 1 2 3 3 3 2 1 1 2 2 2 2 2 1 1 1 1 1 1 1 1 include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char **argv) { if (argc != 2) { printf("usag ...
Global site tag (gtag.js) - Google Analytics