class Solution {
public:
vector<string>v;
void InOrder(TreeNode*root,vector<int>&path)
{
if(root)
{
path.push_back(root->val);
//到叶子结点
if(root->left==NULL&& root->right==NULL)
{
string temp="";
for(int i=0;i<path.size();i++)
temp=temp+to_string(path[i])+"->";
temp.pop_back();
temp.pop_back();
v.push_back(temp);
}
else
{
InOrder(root->left,path);
InOrder(root->right,path);
}
path.pop_back();
}
}
vector<string> binaryTreePaths(TreeNode* root)
{
vector<int>path;
InOrder(root,path);
return v;
}
};