摘要: #include <iostream>#include <string>#include <map>#include <iterator>#include <cstdio>using namespace std;int main(){ string s; int cnt=0; map<string,int> tree;//一对一映射 while(getline(cin,s)) { tree[s]++;//数组方式 cnt++; } map<string,int>::iterator iter; for(iter 阅读全文
posted @ 2012-08-07 23:44 加拿大小哥哥 阅读(641) 评论(0) 推荐(0)
摘要: //由先中序建树,然后后序遍历 #include <cstring>#include <string>#include <iostream>#include <cstdlib>using namespace std;typedef struct Node{ char data; Node *lchild,*rchild;}Node,*Bitree;Bitree creat(string s1,string s2){ if(s1.length()==0)//到叶子节点 return NULL; Node *root = new Node; if(! 阅读全文
posted @ 2012-08-07 13:19 加拿大小哥哥 阅读(256) 评论(2) 推荐(0)
摘要: /*字符串匹配,(模式串 主串)区分大小写*/ #include <cstdio>#include <cstring>#include <cstdlib>using namespace std;const int N = 100010;char str1[N],str2[N];bool is_match(){ int i,j; if(strlen(str1)>strlen(str2)) return false; for(j=i=0;str1[i]!='\0'&&str2[j]!='\0';j++) if 阅读全文
posted @ 2012-08-07 00:07 加拿大小哥哥 阅读(175) 评论(0) 推荐(0)