//统计关键字的个数
#include
#include
#include
#define MAXWORD 100 //关键字最大的个数
struct key{
}keytab[]={
};
//关键字的个数等于数组的长度除以单个元素的长度
#define NKEYS (sizeof keytab/sizeof(struct key))
int getword(char *,int );//从输入中读取下一个字符或者单词
int binsearch(char *,struct key *,int );
//从tab[0]到tab[n-1]中查找单词
int main()
{
}
//binsearch:find word in tab[0],...tab[n-1]
//折半查找
int binsearch(char *word,struct key tab[],int n)
{
}
//getword从输入中读取下一个单词是
//以字母开头的字母和数字串
//也可以是以字母开头的字母和数字串
//也可以是一个非空白字符串
//函数返回值可能是单词的第一个字符、
//文件结束符EOF或字符本身(如果不是字符或者字母本身)
int getword(char *word,int lim)
{
}
#define BUFSIZE 100//缓冲区的大小
char buf[BUFSIZE]; //用于ungetchar函数的缓冲区
int bufp=0;//buf中下一个空闲位置
//读取一个字符(可能是压回的字符)
int getch(void)
{
}
//把字符压回到输入中
void ungetch(int c)
{
}
//二叉树统计单词的个数,若单词第一次出现,则产生新的树节点
#include
#include
#include
#include
#define MAXWORD 100
struct tnode{//树的节点
};
struct tnode *addtree(struct tnode *,char *);
struct tnode *talloc(void);
char *strdup(char *);
void treeprint(struct tnode *);
int getword(char *,int);
int main()
{
}
//在p的位置或者p的下方增加一个w节点
struct tnode *addtree(struct tnode *p,char *w)
{
}
//递归打印树,在每个节点,先打印左子树(小于该单词的所有单词)
//然后是该单词本身,最后是右子树(大于该单词的所有单词)
void treeprint(struct tnode *p)
{
}
//创建一个node节点
struct tnode *talloc(void)
{
}
//复制s
char *strdup(char *s)
{
}
//getword从输入中读取下一个单词是以字母开头的字母和数字串
//也可以是以字母开头德字母和数字串,也可以是一个非空白字符串
//函数返回值可能是单词的第一个字符,文件结束符EOF或者字符本身
//如果该字符不是字母字符本身
int getword(char *word,int lim)
{
}
#define BUFSIZE 100//缓冲区的大小
char buf[BUFSIZE];//用于ungetchar函数的缓冲区
int bufp=0;//buf中下一个空闲位置
//读取一个字符,可能是压回的字符
int getch(void)
{
}
//把字符压回输入中
void ungetch(int c)
{
}