1020 - #include<iostream> #include<algorithm>...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<algorithm> #include<string> #include<vector> #include<cstring> #include<cstdlib> #include<cstdio> using namespace std; enum { SIZ = 104, ALP = 26, }; struct Node { unsigned mask; Node *lnk[ALP]; }; Node *head; Node *next = 0; int ansCnt; char one[ALP+1]; int dc[ALP+1]; bool vis[ALP+1]; char buf[SIZ]; int freq[ALP]; int tst[ALP], tnum; vector<string> wd; Node *getNode(){ Node *p; if (next){ p = next; next = next->lnk[0]; } else { p = (Node*)malloc(sizeof(Node)); } memset(p, 0, sizeof(Node)); return p; } void putNode(Node *p){ p->lnk[0] = next; next = p; } void release(Node *p){ if (p == 0) return; int i; for (i=0; i<ALP; ++i){ if (p->lnk[i]){ release(p->lnk[i]); } p->lnk[i] = 0; } putNode(p); } Node * insert(Node *h, char c){ c -= 'A';
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
if (h->lnk[c] == 0){ h->lnk[c] = getNode(); } h = h->lnk[c]; return h; } struct cmp{ return freq[a] > freq[b]; } }; if (p==0) return false;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/18/2010 for the course CS 100 taught by Professor Acm during the Spring '10 term at Zhejiang University.

Page1 / 4

1020 - #include&lt;iostream&gt; #include&lt;algorithm&gt;...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online