wordhash.main.c
来自「一个C语言写的快速贝叶斯垃圾邮件过滤工具」· C语言 代码 · 共 50 行
C
50 行
/* $Id: wordhash.main.c,v 1.10 2005/03/16 03:37:13 m-a Exp $ */#include "common.h"#include "wordhash.h"typedef struct{ int count;}wh_elt_t;/* function definitions */static void word_init(void *vw){ wh_elt_t *w = vw; w->count = 0; }static voiddump_hash (wordhash_t * h){ hashnode_t *p; for (p = wordhash_first (h); p != NULL; p = wordhash_next (h)) { word_t *key = p->key; (void)word_puts(key, 0, stdout); (void)printf (" %d\n", ((wh_elt_t *) p->buf)->count); }}intmain (void){ wordhash_t *h = wordhash_new (); char buf[100]; wh_elt_t *w; while (scanf ("%99s", buf) != EOF) { word_t *t = word_news(buf); w = wordhash_insert (h, t, sizeof (word_t), &word_init); w->count++; } dump_hash (h); wordhash_free (h); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?