poj 1577
来源:互联网 发布:top是什么域名 编辑:程序博客网 时间:2024/05/16 08:41
题不难,数据结构之BST,就是输入纠结了一会
#include <iostream>#include <cstring>using namespace std;const int maxn=30;struct Tnode{char data; Tnode * lchild;Tnode * rchild;};Tnode * root;void insert(Tnode * p,char c){if(root==NULL){root=new Tnode;root->data=c;root->lchild=NULL;root->rchild=NULL;}else{if(c>p->data){if(p->rchild==NULL) {p->rchild=new Tnode;p->rchild->data=c;p->rchild->lchild=NULL;p->rchild->rchild=NULL;}elseinsert(p->rchild,c);}else{if(p->lchild==NULL) {p->lchild=new Tnode;p->lchild->data=c;p->lchild->lchild=NULL;p->lchild->rchild=NULL;}elseinsert(p->lchild,c);}}}void print(Tnode * p){if(p==NULL) return;cout<<p->data;print(p->lchild);print(p->rchild);}int main(){char tem[maxn][maxn];int flag=1;while(flag){int count=0;while(cin>>tem[count]){if(tem[count][0]=='$'){flag=0;break;}if(tem[count][0]=='*') break;count++;}root=NULL;int i,j;int len=strlen(tem[2]);for(i=count-1;i>=0;i--){for(j=0;j<strlen(tem[i]);j++)insert(root,tem[i][j]);}print(root);cout<<endl;}return 0;}
- POJ-1577
- poj 1577
- poj 1577
- POJ-1577-Falling Leaves
- POJ 1577 Falling Leaves
- POJ 1577 Falling Leaves
- poj 1577 Falling Leaves
- POJ 1577 Falling Leaves
- poj 1577 Falling Leaves
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- 对ArrayList中的元素按照某一列进行排序
- Use JClaim libraries to write IM-enabled applications
- C# 16进制与字符串、字节数组之间的转换
- WCF从理论到实践系列文章
- 我的WCF之旅
- poj 1577
- 为什么ostream_iterator 是未定义标示符
- 爱情如江南的青花瓷
- 游戏-钓鱼岛保卫战
- java导出excel文件
- MySQL加速查询速度的独门武器:查询缓存
- C++中的~的意思,析构函数和构造函数
- js+ExtJs+Ajax 解析xml文件
- WCF实现REST