上来一看感觉难以下手,仔细想想就是dfs啊!!!!
1 #include <cstdio> 2 #include<iostream> 3 #include<iomanip> 4 #include<cstring> 5 #include<string> 6 #include<queue> 7 #include<algorithm> 8 using namespace std; 9 int n=0; 10 char s[210][210]; 11 void dfs (int x,int y) 12 {//x为第几行,y为某一行的第几个 13 cout<<s[x][y]<<'('; 14 if(x+1<n&&s[x+1][y]=='|')//如果有子树,就向下搜 15 { 16 int kk=y; 17 while(kk-1>=0&&s[x+2][kk-1]=='-')kk--;//找到最左边 18 while(s[x+2][kk]=='-'&&s[x+3][kk]!='