0_0_13801550_14657.cpp:1:9: error: #include expects "FILENAME" or <FILENAME>
#include#include#include#includeusing namespace std;char str[12];const int maxn=26;//孩子节点的最大个数,如果是只有26个字母,就用26就可以了。struct Trie//树的结构体{ int cnt;//保存某个字母出现的次数 Trie *next[maxn];//每一个节点对应着多少个孩子,如果只有26个字母,就用26就可以了};Trie root;/*void init(Trie t){ for(int i=0;inext[id]==NULL)//第一次遇到 { q=(Trie*)malloc(sizeof(Trie)); q-cnt=1;//此处一开始写错,写成了q-cnt++; for(int i=0;inext[i]=NULL;//初始化非空节点的孩子节点 p-next[id]=q;//在树中填上 p=p-next[id];//此时的P是不为空的节点 } else { p-next[id]-cnt++;//不是第一次遇到,个数++ p=p-next[id]; } }}int find(char *str){ int len=strlen(str); Trie *p=&root; for(int i=0;inext[id];//一直向下走。 if(p==NULL)//找不到该单词,一开始此处写错了,写成了p-next[id]==NULL return 0; } return p-cnt;}int main(){ while(gets(str)&&str[0]!='\0') { CreateTrie(str); } while(scanf("%s",str)!=EOF) { printf("%d\n",find(str)); } return 0;}
^
|