数据结构实验之查找一:二叉排序树
来源:互联网 发布:linux session 编辑:程序博客网 时间:2024/06/06 08:29
#include<bits/stdc++.h>using namespace std;typedef struct node{ char data; struct node *lchild; struct node * rchild;}node, *Tree;char a[200],b[200];int st1[200],st2[200];int i,j;Tree creat(Tree &t,char x){ if(t==NULL) { t=new(node); t->data=x; t->lchild=NULL; t->rchild=NULL; } else { if(x<t->data) { t->lchild=creat(t->lchild,x); } else { t->rchild=creat(t->rchild,x); } } return t;}void xian(Tree &t){ if(t!=NULL) { a[i++]=t->data; xian(t->lchild); xian(t->rchild); }}void xiannext(Tree &t){ if(t!=NULL) { b[j++]=t->data; xiannext(t->lchild); xiannext(t->rchild); }}int main(){ int n,l; Tree t1,t2; while(cin>>n&&n) { cin>>l; t1=NULL; for(i=0;i<n;i++) { cin>>st1[i]; t1=creat(t1,st1[i]+'\0'); } i=0; xian(t1); a[i]='\0'; while(l--) { t2=NULL; for(j=0;j<n;j++) { cin>>st2[j]; t2=creat(t2,st2[j]+'\0'); } j=0; xiannext(t2); b[j]='\0'; if(strcmp(a,b)) { cout<<"No"<<endl; } else { cout<<"Yes"<<endl; } } }}
0 0
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- SDUT3373数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- SDUTACM 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- 数据结构实验之查找一:二叉排序树
- ASP.NET中MD5和SHA1加密的几种方法
- CodeForces 680A Bear and Five Cards(取数字)
- js作用域
- 激励自我!向着大牛的背影进发!
- camera otp
- 数据结构实验之查找一:二叉排序树
- MySQL---数据库从入门走向大神系列(十四)-ComboPooledDataSource(C3P0连接池配置)
- listview的重要属性viewtype,实现多类型item样式
- leetcode Trapping Rain Water
- 用纯JAVA语言编程读取MAC地址的实现
- JavaScript 实现类似Java Map对象
- BCB编程规范
- java编程过程中的if语句
- VS的MFC项目生成不依赖运行时不依赖MFC的程序