SSH:git@git.coding.net:jlspduqiao/word-frequency-count.git
#include <stdlib.h> #include <stdio.h> #include <string.h> typedef struct LNode { char c[20]; int count; struct LNode *next; }LNode,*LinkList; struct LNode *Create() { LinkList L; L=(LinkList)malloc(sizeof(LNode)); L->next=NULL; return L; } void Print(LinkList L) { struct LNode *p; p = L->next; if(p!= NULL) { do { printf ("%s %d ", p->c, p->count); p = p->next; } while (p != NULL); } } bool Find(LinkList &L,char a[20])//查找单词 { LNode *p; p=L->next; while(p!=NULL) { if(strcmp(a,p->c)==0){//找到单词 p->count++;//计数加一 return true; } else p=p->next; } return false; } void Insert(LinkList &L,char a[20]) { LNode *p; p=(LinkList)malloc(sizeof(LNode)); strcpy(p->c,a); p->count=1; p->next=L->next; L->next=p; } int main(){ struct LNode *L=Create(); char a[20]; char c; int i=0; printf("请输入: "); while ((c = getchar()) != ' '){//读入并判断是否输入了回车(回车结束) if(c!=' '&&c!='.'&&c!=','&&c!='?'&&c!=':'){ a[i]=c; a[i+1]='