10562 - Undraw the Trees
来源:互联网 发布:linux deploy 安装 编辑:程序博客网 时间:2024/05/29 12:29
这道题不是二叉树形式的,没法建二叉树,不过可以通过建二叉树的方法来做,不过这道题刚开始就考虑错了,以为只有字母是节点,其实还包括数字等字符,结果交了好几次wa……可惜啊#include <iostream>#include <cstring>#include <cstdio>using namespace std;void dfs(char s[210][210],int row,int clow,int len){ int k,l; for( k=clow; s[row][k]=='-'; k++) if(s[row+1][k]!=' '&&s[row+1][k]&&s[row+1][k]!='#') { printf("%c(",s[row+1][k]); if(row+2<len&&s[row+2][k]=='|') { for(l=k; l&&s[row+3][l-1]=='-'; l--); dfs(s,row+3,l,len); } printf(")"); }}int main(){ //freopen("a.txt","r",stdin); int n,i,j; scanf("%d",&n); getchar(); char str[210][210]; while(n--) { i=1; memset(str,0,sizeof(str)); while(gets(str[i])) { if(str[i][0]=='#')break; i++; } printf("("); for(j=0; j<strlen(str[1]); j++)str[0][j]='-'; dfs(str,0,0,i); printf(")\n"); } return 0;}
- 10562 - Undraw the Trees***
- 10562 - Undraw the Trees
- 10562 - Undraw the Trees
- 10562 - Undraw the Trees
- 10562 - Undraw the Trees
- 10562 - Undraw the Trees
- uva 10562 - Undraw the Trees
- uva 10562 - Undraw the Trees
- uva 10562 - Undraw the Trees
- UVa 10562 - Undraw the Trees
- UVA 10562 - Undraw the Trees
- UVA 10562 Undraw the Trees
- uva 10562 - Undraw the Trees
- uva 10562 - Undraw the Trees
- UVa 10562 - Undraw the Trees
- UVA 10562 Undraw the Trees
- UVA - 10562 Undraw the Trees
- uva-10562Undraw the Trees
- 'operator =' must be a <Unknown> member
- Debug
- 浅谈C/C++内存泄漏及其检测工具
- 库函数
- 在O(1)时间内删除链表结点
- 10562 - Undraw the Trees
- [笔试题]查找一个字符串在另一个字符串中的连接次序
- PPM Object中对于Delegated Owner的错误图标指示问题
- Oracle PL/SQL 示例
- 杭电acm-2201熊猫阿波的故事
- Agile PLM: 启动时匪夷所思的的Node (18387 , 2490533) does not exist in the cache
- char*参数构造函数和string参数构造函数
- 定时任务 java.util.Timer和TimerTask
- NTFS压缩过程中电脑断电的问题