汉语提,题意清楚。当初还卡了我一个上午。哎。
ac代码:
View Code
#include#include #include #include #include #include #include using namespace std;const int maxn=26;struct node{ int cnt; node *next[maxn]; node() { cnt=0; for(int i=0;i next[num]==NULL) location->next[num]=new node(); location->next[num]->cnt++; location=location->next[num]; } } int Search(string str) { node *location=root; for(int i=0;i next[num]==NULL) return 0; location=location->next[num]; } return location->cnt; }}t;int main(){ char ss[20]; string str; while(cin.getline(ss,20) ) { str = ss; if(str== "") break;// for(int i = 0 ;i < strlen(ss); i ++) str += ss[i];// cout << "str == " << str << endl; t.Insert(str);// getchar();// ch = getchar(); } while(cin.getline(ss,20)) {// cout << "fff " << str << endl; str=ss; cout< <
欢迎批评指正。谢谢!